retreive the value of the radio button
Status: Curious
Joined: 31 Mar 2005
Posts: 7
Reply Quote
How do I retrieve the values of the selected radio button.

My html is as follows:

<input type=radio name=sel value=’testA’ id=13A onclick=test();>

<input type=radio name=sel value=’testB’ id=13B onclick=test();>

This statement always retrieves the first radio button which is testA

The ids are different, so what is the syntax to retrieve the values by id.

Back to top
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
If you are using javascript, you have to use a slightly different method for extracting data from radio button lists:

:: Code ::
for (i = 0;  i < theForm.sel.length;  i++)
   if (theForm.sel[i].checked)
   alert( theForm.sel[i].value );

theForm would be the name of the form.

You're getting the first item in the radio button array because you're not looping through it is my guess.
Back to top
Display posts from previous:   

All times are GMT - 8 Hours