Input Radio value Property - Change the value of the value attribute of a radio button: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Radio

Description

Input Radio value Property - Change the value of the value attribute of a radio button:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<input type="radio" name="colors" value="red" id="myRadio">Red color

<button onclick="display()">Display name</button>
<button onclick="change()">Change name</button>

<script>
function display() {
    var x = document.getElementById("myRadio").value;
    console.log("The value of the radio button is: " + x);
}

function change() {//from  w ww  . ja  v  a2  s .c o m
    var x = document.getElementById("myRadio").value = "newRadioBtnValue";
    console.log("The value was changed to: " + x);
}
</script>

</body>
</html>

Related Tutorials