Webmaster

HTML : Fill-In Forms
Contents ]
Jérôme Versavel

Checkboxes and Radio Buttons

To allow your visitors to make choices between several items or answers, you can provide checkboxes or radio buttons.

Checkboxes

Checkboxes are little on/off switches in the form of squares that display a tick mark when they are set. Several checkboxes grouped under one topic can be checked.

Example:

You use Internet:<BR>
<INPUT TYPE="checkbox" NAME="internet" VALUE=" home"> at home<BR>
<INPUT TYPE="checkbox" NAME="internet" VALUE="work"> at work<BR>

Here is the rendering

at home
at work


These boxes are defined by the <INPUT TYPE="checkbox"> which has two attributes:

  • VALUE,****** which is the answer given by the visitor.

  • This is the attribute you must test when processing the form data.

  • CHECKED, the Boolean value of which is set or not set to indicate whether or not the box is checked.

Logically related buttons. All tags relating to the same topic or question must be given the same value for the NAME attribute (which represents the question) and different values for the VALUE attribute (which represents a specific answer.)

Radio buttons

Unlike checkboxes, radio buttons allow the visitor to make only one choice within a group of related options.

Example:

<INPUT TYPE="radio" NAME="age" VALUE="18-25"> 18 - 25 years old<BR>
<INPUT TYPE="radio" NAME="age" VALUE="26-35"> 26 - 35 years old<BR>
<INPUT TYPE="radio" NAME="age" VALUE="36-45"> 36 - 45 years old<BR>

Here is the rendering:

18 - 25 years
26 - 35 years
36 - 45 years


Radio buttons are defined with the <INPUT TYPE="radio"> tag and accept the same attributes as checkboxes.



  1   2   3   4   5   6