Javascript Form How to - Get RadioButton value property








Question

We would like to know how to get RadioButton value property.

Answer


<!--from w w  w . j  a v  a  2  s  .co  m-->
<html>
<body>
    <form name="form1">
    <input type="radio" name=button1 value=1>Box 1
    <br><br>
    <input type="button" value="Get Button Value"
    onClick='console.log("The button value is: " + document.form1.button1.value)'>
    </form>
</body>
</html>

The code above is rendered as follows: