<!DOCTYPE html>
<html>
<body>
<input type="radio" name="colors" value="red" id="myRadio">Red color
<p>Click the buttons below to display and/or change the value of the value attribute of the radio button.</p>
<button onclick="display()">Display name</button>
<button onclick="change()">Change name</button>
<script>
function display() {
var x = document.getElementById("myRadio").value;
alert("The value of the radio button is: " + x);
}
function change() {
var x = document.getElementById("myRadio").value = "newRadioBtnValue";
alert ("The value was changed to: " + x);
}
</script>
</body>
</html>