Forum : How to find radio button selection when a form is submitted?
Brief description  about Online courses   join in Online courses
View Balu  Prasad 's Profile

How to find radio button selection when a form is submitted?

Hi sir,

How to find radio button selection when a form is submitted?
Asked by Balu Prasad | Nov 27, 2009 |  Reply now
Replies (1)
View teacher siliconindia 's Profile
Hi balu,

Go through the code given below:

<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" action="">
<input type="radio" name="marsupial" value="kangaroo" />Kangaroo
<br /><input type="radio" name="marsupial" value="Opossum" />Opossum
<br /><input type="radio" name="marsupial" value="Tasmanian Tiger" />Tasmanian Tiger


<input type="button" name="GO" value="GO" onclick="findButton()" />
Nov 27, 2009