|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have a simple question that I can't seem to find an answer to any where else:
What do I need to do to find out which radio button is "checked," for the purpose of writing a cookie depending on which option is selected. I've tried to do it as I would a checkbox, but can't get it or any variations to work. Any help would be most appreciated. Thank you! HyperWhiz aka Tyler |
|
#2
|
|||
|
|||
|
It'd be easier to help if you provide a code sample, but here goes:
First off, I checked the Javascript reference at http://developer.netscape.com and it appears that radio buttons have a "checked" property just like checkboxes do, but in an array, one per button. A code example: <script language="JavaScript"> <!-- function test() { for (i=0; i<document.myForm.myRadio.length; i++) { if (document.myForm.myRadio[i].checked) { alert(document.myForm.myRadio[i].value); } } } // --> </script> </head> <body> <form name="myForm"> <input type="radio" name="myRadio" value="first"><br> <input type="radio" name="myRadio" value="second"> <p> <input type="button" value="test" onClick="test()"> </form> </body> Hope this helps, Ton [This message has been edited by tvanbart (edited October 08, 2000).] |
|
#3
|
|||
|
|||
|
Yes, that answered my question perfectly. Thank you very much!
HyperWhiz aka Tyler |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > Simple radio button validation problem... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|