- <input type="radio">
-
Creates a radio button. Radio buttons
are used where there is a single question with a fixed
and finite set of possible answers and only one answer can be selected.
Usually, one radio button is provided
for each possible answer and only one of the radio buttons can be
selected at once. In order to achieve this behaviour, all of the
radio buttons for a single question must have the same
name attribute. Conversely, each radio button for a single
question must have a different value attribute.
An example of the use of radio buttons
is shown on lines 18 and
19 of Figure 6.2
and in Figure 6.1.
- <input type="checkbox">
-
Creates a check box.
Each check box corresponds to a yes/no question, so each
check box should have a unique name attribute.
When a form is submitted, information is only sent
for check boxes that have been selected, so the program
processing the data must know about all check boxes in order
to record a missing value or “off” value for check boxes that
were not selected.
An example of the use of check boxes
is shown on lines 23 and
24 of Figure 6.2
and in Figure 6.1.
- <input type="text">
-
Creates a region for entering
small amounts of text. A default value can be supplied via
the value attribute. The maximum number of characters
that can be entered can be controlled via the maxlength
attribute, but otherwise the value entered by the user is
unconstrained. See Section 6.4.
An example of the use of a text component
is shown on lines 12 to
14 of Figure 6.2
and in Figure 6.1.
- <textarea>
-
Creates a region for entering large amounts
of text. The size of the region that is displayed on the web page
is controlled via rows and cols attributes. The values
of these attributes are taken to be a number of lines of text and
a number of characters of text, respectively. A default value
can be supplied as the contents of the textarea element
(white space is literal within this content).
An example of the use of a text region
is shown on line 44 of Figure 6.2
and in Figure 6.1.
- <input type="password">
-
Creates a region for entering
a password; key strokes are echoed by printing dots or stars
so that the actual value being entered is not visible on screen.
- <select>
-
Creates a selection menu. The options
on the menu are created by option elements within the menu
element. The content of the option element is displayed on the
menu. The data value that is recorded for each option
element is also taken from the content of the option element
unless the option element has a value attribute.
The label for the data value comes from the name attribute
of the select element (the option elements have no
name attribute).
An example of the use of a selection menu
is shown on lines 34 to
41 of Figure 6.2
and in Figure 6.1.
- <input type="submit">
-
Creates a submit button.
The label on the button can be controlled via the value
attribute. Clicking this button will send the form data to
a program for processing (see Section 6.3).
An example of the use of a submit button
is shown on line 47 of Figure 6.2
and in Figure 6.1.
- <input type="reset">
-
Creates a reset button. Clicking
this button will reset the values of all controls to their default values.
An example of the use of a reset button
is shown on line 48 of Figure 6.2
and in Figure 6.1.
- <button>
-
Creates a button. This can be used as an alternative
way to create a button for submitting
the form, resetting the form, or, more generally, for associating a mouse
click with a script action (see Section 6.4).
The label on the button is taken from the contents of the button
element (so this allows for fancier button labels, including images).
An example of the use of a generic button
is shown on line 49 of Figure 6.2
and in Figure 6.1.
- <label>
-
Associates a text label with a form component.
Useful for non-graphical browsers and just as a discipline for
documenting code.
For radio buttons and check boxes this means that a click on the
text will select the corresponding radio button or check box.
- <input type="hidden">
-
Generates an invisible form data value. This can be used to
include information with the form data, but have nothing displayed on
the web page.
An example of the use of a hidden element
is shown on line 51 of Figure 6.2.
The purpose of this element is described in Section
6.4.2.