9.2 XHTML—Using Forms^359
Figure 9.7
Use a check box
when one or more
selections is
appropriate
The XHTML code follows:
Choose the browsers you use:<br />
<input type="checkbox" name="IE" id="IE" value="yes" />
Internet Explorer<br />
<input type="checkbox" name="Firefox" id="Firefox" value="yes" />
Netscape<br />
<input type="checkbox" name="Opera" id="Opera" value="yes" /> Opera
Note that the value of all the check boxes just happened to be yes. You can set the
value to be any meaningful word or phrase. The name of each check box should be
unique.
Common check box attributes are listed in Table 9.4.
Radio Button. The <input />tag configures this form control. Radio buttons allow
the user to select exactly one item from a group of predetermined items. Each radio
button in a group is given the same name and a unique value. Because the name is the
same, the elements are identified as part of a group and only one may be selected. A
sample radio button group is shown in Figure 9.8.
Table 9.4Common check box attributes
Attribute Values Usage
type checkbox Configures the check box.
name Alphanumeric, no spaces,
begins with a letter
Names the form element so that it can be easily accessed by client-
side scripting languages or by server-side processing. The name of
each check box should be unique.
id Alphanumeric, no spaces,
begins with a letter
Provides a unique identifier for the form element.
checked checked Configures the check box to be checked by default when displayed
by the browser.
value Text or numeric characters Assigns a value to the check box that is triggered when the check
box is checked. This value can be accessed by client-side and by
server-side processing.
Figure 9.8
Use radio buttons
when only one
choice is an
appropriate response