Tryit Editor v2.3

Edit This Code:
<!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> <!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_radio_value2 by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:33:27 GMT --> </html>
Result:
Try it Yourself - © w3schools.com