University of Virginia Department of
    Computer Science

Acknowledgements

Thanks go to Michael Grobe at the University of Kansas for letting us use his work following.


HTML Forms Interface

The HTML forms interface allows document creators to define HTML documents containing forms to be filled out by users. When a user fills out the form and presses a button indicating the form should be "submitted," the information on the form is sent to a server for processing. The server will usually prepare an HTML document using the information supplied by the user and return it to the client for display.

The following tags implement the forms interface:

The last four tags can only be used within a <form> . . . </form> element.

Define a form

<form> . . . </form>

Define a form within an HTML document. A document may contain multiple <form> elements, but <form> elements may not be nested. Note that non-form tags can be used within a <form> element. Attributes and their arguments:

action="URL":
The location of the program that will process the form.
method=data_exchange method
The method chosen to exchange data between the client and the program started to process the form: One of get or post. post is preferred for most applications.
Example:
<form action="http://kuhttp.cc.ukans.edu/cgi-bin/register" method=post> . . . </form>

Define an input field

<input> (there is no ending tag)

Defines an input field where the user may enter information on the form. Each input field assigns a value to a variable which has a specified name and a specified data type. Attributes and their arguments:

type="variable_type"
Specifies the data type for the variable, where:
name="textstring"
where textstring is a symbolic name (not displayed) identifying the input variable as in:
<input type="checkbox" name="box1">
value="textstring"
where the meaning of textstring depends on the argument for type.

checked
No arguments. For type="checkbox" or type="radio", if checked is present the input field is "checked" by default.
size="display_width"
where display_width is an integer value representing the number of characters displayed for the type="text" or type="password" input field.
maxlength="string_length"
where string_length is the maximum number of characters allowed within type="text" or type="password" variable values. This attribute is only valid for single line "text" or "password" fields.

Define a select field

<select> . . . </select>

defines and displays a set of optional list items from which the user can select one or more items. This element requires an <option> element for each item in the list. Attributes and their arguments:

name="textstring"
where textstring is the symbolic identifier for the select field variable.
size="list_length"
where list_length is an integer value representing the number of <option> items that will be displayed at one time.
multiple
No arguments. If present, the multiple attribute allows selection of more than one <option> value.

Define a select field option

<option>

Within the <select> element the <option> tags are used to define the possible values for the select field. If the attribute selected is present then the option value is selected by default. In the following example all three options may be chosen but bananas are selected by default.

<select multiple>
<option>Apples
<option selected>Bananas
<option>Cherries
</select>

Define a text area

<textarea> . . . default text . . . </textarea>

Defines a rectangular field where the user may enter text data. If "default text" is present it will be displayed when the field appears. Otherwise the field will be blank. Attributes and their values:

name="textstring"
textstring is a symbolic name that identifies the <textarea> variable.
rows="num_rows" and cols="numcols"
Both attributes take an integer value which represents the lines and number of characters per line in the <textarea> to be displayed.


HelpNet
HelpNet was created by the 1995 incoming graduate class. It is only occasionally updated.
Department of Computer Science
School of Engineering, University of Virginia
151 Engineer's Way, P.O. Box 400740
Charlottesville, Virginia 22904-4740

(434) 982-2200  Fax: (434) 982-2214
Web Comments: webteam@cs.virginia.edu
Admissions Inquiries: inquiry@cs.virginia.edu
Site directory, Other addresses
Server statistics
© Created by the CS Web Team