programming.nbk: Home | Index | Next Page: HTML: Forms: selection list | Previous Page: HTML: Forms: checkbox
Radio buttons come in groups. They are bound together as a group by having the same name:
<INPUT TYPE="radio" NAME="rad" VALUE="radio_button1"> <INPUT TYPE="radio" NAME="rad" VALUE="radio_button2"> <INPUT TYPE="radio" NAME="rad" VALUE="radio_button3"> <INPUT TYPE="radio" NAME="rad" VALUE="radio_button4">
A particular radio button can be preselected with the "CHECKED" attribute:
<INPUT TYPE="radio" NAME="rad" Value="rad_button1" CHECKED>
Or with Javascript:
form.rad[0].checked = true; // sets to first button in the rad group
Finding the selected radio button with Javascript:
function test_radio_button (form){ for (Count = 0; Count < 3; Count++) { if (form.rad[Count].checked) break; } alert ("Button " + Count + " is selected"); }
programming.nbk: Home | Index | Next Page: HTML: Forms: selection list | Previous Page: HTML: Forms: checkbox
Notebook exported on Monday, 7 July 2008, 18:56:06 PM Eastern Daylight Time