Forms

The FORM tag and its associated tags provide a means of obtaining user input. Unlike other tags, the Form requires an associated program to perform its tasks. These programs can either be transmitted with the Web page (using JavaScript, for example) or run from the server that transmits the page (using CGI, for example). It is well beyond the scope of this tutorial to show how to program using either method. Contact your Systems Department to determine who can assist you if your Web page requires a form.

<form {method="get|post" action="url " enctype="type_literal" name="script_reference"}> form_data </form>

All attributes are optional. Whoever programs the script that accompanies your form will fill in the correct values for any parameters that need to be set. For completeness:

Any HTML tag can be placed inside a Form. In addition to the standard tags, there are several special tags for gathering user input.

Labels

<label for="element_id"> label_text </label>

A Label is used to associate text with an active element. Click the label text with change the state of checkboxes and radio buttons, activate buttons and place the cursor in text boxes. The element_id must be unique for each element, but more than one label can control the same element.

Input Widget

<input type="checkbox|radio|hidden|reset|submit|image|button|text|password" name="script_reference" id="element_id" value="value" checked size="# of text characters" maxlength="max # of text characters" readonly src="image_url" align="top|middle|bottom|left|right" alt="text" border="pixels" />
INPUT is a general purpose tag whose appearance and function varies depending on the parameters used. TYPE determines the general appearance and function of the input device. For example:
    
    

    
    
    



    

    

    

The attributes are:

TextArea Box

<textarea name="script_reference" cols="# of text characters" rows="# of text characters" readonly"> default_text </textarea>
   
TEXTAREA provides a way to receive multiple lines of text complete with carriage returns. Any text between the opening and closing tags will appear in the box by default. The attributes are:

Select List

<select name="script_reference" {size="#_of_displayed_selections" multiple disabled}>
<optgroup label="
group_label">
<option value="
value" disabled> list_text </option>
...
...
<option value="value" disabled> list_text </option>
</select>
SELECT Examples
Select List
(no SIZE)
    Select List
(size="4")
Item 3 selected
Two Option Groups
   

SELECT provides a method to choose from a list of options. The selected Option's Value is sent to the server when the form is submitted. The attributes for Select are: OPTION statements create the entries in the list. The list_text is displayed in the list to identify the selection. The attributes for the Option statement are: OPTGROUP statements group the option entries below them. NOTE: if a class or style is assigned to an Option group it will apply to all options within the group. The attributes for the Optgroup statement are:


Next Lesson Next Page

HTML Home