This example describes how JavaScript determines which radio button is selected when the form is submitted. Share to everyone for your reference. The specific analysis is as follows:
When the form is submitted here, you can tell by JavaScript which radio button is selected.
<script type= "Text/javascript" >
function Findbutton () {
var myForm = document.forms.animalForm;
var i;
for (i=0;i<myform.marsupial.length; i++) {
if (myform.marsupial[i].checked) {break
;
}
}
Alert ("you selected \" "+myform.marsupial[i].value+" \ ".");
}
</script>
<form name= "Animalform" >
<input type= "Radio" name= "marsupial" value= "kangaroo"/ >jb51.net <br/> <input type= "Radio" name= "marsupial" value=
"Opossum"/>opossum
< br/>
<input type= "Radio" name= "marsupial" value= "Tasmanian tiger"/>tasmanian Tiger
<br/>< C19/><input type= "button" name= "Go" value= "Go" onclick= "Findbutton ()"/>
</form>
I hope this article will help you with your JavaScript programming.