Forms in the Web
WWW-browsers
can be used as user-interface for all sorts of programs.
Examples are information retrieval tools for the Web itself,
such as Alta Vista,
multiple-choice tests,
and databases and expert systems, like the services offered by
real-estate agents or the
dutch railways.
A form contains a number of INPUT, SELECT and TEXTAREA fields.
The INPUT fields are of one of the following types:
- CHECKBOX: can be on or off. Mosaic shows them as small squares.
Checkboxes are typically used to select one or more items from a list.
- RADIO: used to select a value from a list. Mosaic shows them
as small diamonds. Radio buttons are used to select exactly one item from
a list.
- TEXT: shows a field in which one can type one line of text.
- PASSWORD: is like a TEXT field, but the typed characters do
not show.
- HIDDEN: is also like a TEXT field, but it is not shown at all.
Like all other fields it can be given a default value, which is passed on
to the WWW-server. This is typically used to identify different occurrences
of the same (or almost the same) form, so a single program can be used
to handle all occurrences of the form.
- RESET: is a button that resets all fields to their default
value.
- SUBMIT: is a button that sends the contents of the form to
the WWW-server for evaluation.
The SELECT fields contain menu "options".
There are a number of other fields that are or were proposed at some point
and that may show up in future versions of the HTML language, like
RANGE, FILE, SCRIBBLE, AUDIO, and IMAGE input fields, some of which provide
more of a multimedia feel to the forms interface.
As a convenience feature, forms that contain only one TEXT input field
accept pressing "Enter" in the text field as a SUBMIT button press.
The TEXTAREA fields show a rectangular field in which several lines of
text can be entered. (The displayed size is specified as ROWS and COLS.)
Example
The following code generates the form below:
<FORM METHOD=POST
ACTION="course-form.cgi">
Your name:
<INPUT TYPE="text" NAME="name" SIZE="50"> <br>
Sex:
<INPUT TYPE="radio" NAME="sex" VALUE="m">m
<INPUT TYPE="radio" NAME="sex" VALUE="f">f <br>
Check here if you are a student:
<INPUT TYPE="checkbox" NAME="student"> <br>
Interest in WWW:
<SELECT NAME="interest">
<OPTION>low
<OPTION>medium
<OPTION>high
</SELECT><br>
Any comments: <br>
<TEXTAREA ROWS=5 COLS=40
NAME="comments">
</TEXTAREA><br>
<INPUT TYPE="reset" VALUE="clear all">
<INPUT TYPE="submit" VALUE="evaluate form">