Determining the Value of the Selected Radio Button : RadioButton Radio : Form Control JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Form Control » RadioButton Radio »

 

Determining the Value of the Selected Radio Button




<html>
<head>
<script language = "JavaScript">
     function getRadioValue(radioObject) {
          var value = null
          for (var i=0; i<radioObject.length; i++) {
               if (radioObject[i].checked) {
                    value = radioObject[i].value;
                    break ;
               }
          }
          return value
     }
</script>
</head>
<body>
    <form name="form1">
    <p><input type=radio name="songs" value="A">A</p>
    <p><input type=radio name="songs" value="B">B</p>
    <p><input type=radio name="songs" value="C">C</p>
    <input type=button value="Show Selected" onClick="alert(getRadioValue(this.form.songs))">
    </form>
</body>
</html>


           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Form Control
» RadioButton Radio