HTML Forms
HTML forms
provide a mechanism for soliciting information from the user and sending
it to the server.
There are three main HTML elements for getting input from the user:
input, select, and textarea. Each of these
elements must have a name parameter which gives a name to the
data that is sent to the server. The server will then use this name
to determine how to handle the data.
The input element
The input element has several variants including checkboxes, textfields,
and file browers. We describe the most common variants below.
All of these variants have the following form:
input element.
The type attribute can have one of the following values:
text, password, checkbox, radio, submit, reset, file, hidden, image, button.
The text and password variants create a textfield in which the user can
enter characters. The initial size is SIZE characters and the textfield
is initialized with the string of characters in "VALUE". The password
variant displays asterisks for each character typed by the user.
The checkbox and radio variants create checkable buttons.
If a button is checked, then its "VALUE" will be sent to the server.
Several buttons can have the same name, in which case the server will
receive several values for that name. The radio variant allows
the user to check at most one of the buttons that share the same name.
The submit variant sends the data to the server when it is pressed
and the reset variant sets all fields in the form to their
initial values.
The last four are more specialized and won't be discussed in detail here:
file is used for selecting a file on the users disk,
hidden is an element that doesn't appear on the webpage (but still
specifies a value to be sent to the server),
image specifies a graphical submit button, and button
is used for client-side scripting, which we do not discuss here.
|
|
Submitting the above form sends an email to the specified unet id, that lists the values of all of the parameters. A typical example is shown below:
textarea elementThis element is used for soliciting multiline input from the user, it has the form
name, you must specify the size of the
textarea in rows and columns.
The select elementThe select element is used to provide a fixed list of choices from which the user must choose. It has the form:
multiple keyword is present in the attribute list of the select
element, then the user is allowed to select several of the options simultaenously;
otherwise, the user can only select one. The value attributes in the
option elements are sent to the server if the item is selected.
If there is no value attribute then the text between the option tags
is sent in its place.
|
|
