Change the value attribute of a radio button:
document.getElementById("myRadio").value = "newRadioBtnValue";
Click the buttons below to display and change the value attribute of the radio button.
<!DOCTYPE html> <html> <body> <input type="radio" name="colors" value="red" id="myRadio">Red color <p id="demo"></p> <button onclick="display()">Display name</button> <button onclick="change()">Change name</button> <script> function display() { var x = document.getElementById("myRadio").value; document.getElementById("demo").innerHTML = "The value of the radio button is: " + x; } function change() {/*from w w w .j a v a 2 s . c o m*/ var x = document.getElementById("myRadio").value = "newRadioBtnValue"; document.getElementById("demo").innerHTML = "The value was changed to: " + x; } </script> </body> </html>