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

<script type="text/javascript">
function findButton() {
var myForm = document.forms.animalForm;
var i;
for(i=0;i<myForm.marsupial.length; i++) {
if(myForm.marsupial.checked) {
break;
}
}
alert("You selected \""+myForm.marsupial.value+"\".");
}
</script>
<form name="animalForm" action="">
<input type="radio" name="marsupial" value="kangaroo" />Kangaroo

<input type="radio" name="marsupial" value="Opossum" />Opossum

<input type="radio" name="marsupial" value="Tasmanian Tiger" />Tasmanian Tiger


<input type="button" name="GO" value="GO" onclick="findButton()" />


0 comments:

Post a Comment