Home >> Forms >> <INPUT ...>
>> TYPE
TYPE = RADIO
RADIO
is used to create a series of choices of which only
one can be selected. The term "radio button" comes from the buttons for
the radio in an automobile, where selecting one radio station
automatically de-selects all the others.
HTML radio buttons are created by using several
<INPUT TYPE=RADIO>
buttons, all with the same
name, but with different
values. For example, this series of buttons allows you to choose one size for a pizza:
this code |
produces this |
<FORM ACTION="../cgi-bin/mycgi.pl">
What size pizza?<P>
<INPUT TYPE=RADIO NAME="pizzasize" VALUE="S">small<BR>
<INPUT TYPE=RADIO NAME="pizzasize" VALUE="M">medium<BR>
<INPUT TYPE=RADIO NAME="pizzasize" VALUE="L">large<P>
<INPUT TYPE=SUBMIT VALUE="submit">
</FORM>
|
|
Note that it is the content of the VALUE
attribute that is sent to the CGI,
not whatever text happens to appear next to the radio button.
If one of the items should be the default selection, use the
CHECKED
attribute:
this code |
produces this |
<FORM ACTION="../cgi-bin/mycgi.pl">
What size pizza?<P>
<INPUT TYPE=RADIO NAME="pizzasize" VALUE="S" >small<BR>
<INPUT TYPE=RADIO NAME="pizzasize" VALUE="M" CHECKED >medium<BR>
<INPUT TYPE=RADIO NAME="pizzasize" VALUE="L" >large<P>
<INPUT TYPE=SUBMIT VALUE="submit">
</FORM>
|
|
If no CHECKED
attribute is used, different browsers have different ways of displaying the initial state of a series of
radio buttons. Netscape and MSIE have none of the buttons selected. Mosaic
selects the first button.