To get radio button selected value using Javascript

by Rekha 2010-03-12 18:12:12

In order to get the value of a radio button using JavaScript, we need to loop through all the radio buttons in that set and then find out the value of the radio button which is checked.

Example:

1
2
3
4



You have to use the following code to retrieve radio button selected value,
for (var i=0; i < document.frm.choice.length; i++) {
if (document.frm.choice[i].checked) {
var radiovalue = document.frm.choice[i].value;
break;
}
}

Tagged in:

1419
like
0
dislike
0
mail
flag

You must LOGIN to add comments