Ford & Mason Ltd
HOME
ABOUT
CONTACT
RESOURCES
ADVERTISING



donations support the development of
cronolog.org
and
refcards.com

next up previous contents index
Next: Single-line text fields Up: Fill-out Forms Previous: The FORM element


Defining fields

The INPUT element is used to define most types of input field, with the exception of multiple-line text input areas, which are defined with the TEXTAREA element, and selections, which are defined with the SELECT element. The type of field defined by the INPUT element is specified by the value of the TYPE attribute. If no TYPE is specified it defaults to TEXT. The following values are permitted:

TEXT
a text field (default type)
PASSWORD
a text field that does not echo the data entered
HIDDEN
an invisible field
CHECKBOX
one of a set of check boxes
RADIO
one of a set of radio buttons
IMAGE
an image that can be clicked on to submit the form
SUBMIT
a button that submits the data
RESET
a button that resets fields to their initial values.

As well as the TYPE attribute, the INPUT element can take a number of other attributes, depending on the field type specified. Not all the attributes make sense for all input types; Table gif shows which attributes are relevant for each input field type. According to the HTML specification, the TYPE value should not be case sensitive; however, the X Window version of Mosaic version 2.4 does not recognize values unless they are specified completely in lower case, and defaults to TYPE="text".

  
Table: Attributes appropriate for different input field types

Each data field, whether defined by the INPUT, SELECT or TEXTAREA element, must be given a name for identification purposes, using the NAME attribute.

The following example shows the HTML for a sample form that contains all possible field types and Figure gif shows how the X Window version of Mosaic displays this document. Individual lines of the HTML code in Figure gif are used to illustrate the definitions of particular types of field that follow:

    <TITLE>Sample Form</TITLE>
    <H1>Sample Form</H1>

<FORM METHOD=POST ACTION="/examples/scripts/cgi-debug/x/y/z">

<P>Text field: <INPUT TYPE="text" NAME="name" SIZE=40 VALUE="XXX">

<P>Text area: <TEXTAREA NAME="textarea" ROWS=5 COLS=30 >Initial data</TEXTAREA>

<P>Password: <INPUT TYPE="password" NAME="password" SIZE=20 VALUE="ABC">

<P>Hidden field: <INPUT TYPE="hidden" NAME="state" VALUE="state-info">

<P>Radio buttons: <INPUT TYPE="radio" NAME="rb" VALUE="A" CHECKED>A <INPUT TYPE="radio" NAME="rb" VALUE="B">B <INPUT TYPE="radio" NAME="rb" VALUE="C">C

<P>Check boxes: <INPUT TYPE="checkbox" NAME="cb" VALUE=1>1 <INPUT TYPE="checkbox" NAME="cb" VALUE=2 CHECKED>2 <INPUT TYPE="checkbox" NAME="cb" VALUE=3>3 <INPUT TYPE="checkbox" NAME="cb" VALUE=4>4 <INPUT TYPE="checkbox" NAME="cb" VALUE=5 CHECKED>5

<P>Selection: <SELECT NAME="s-field" > <OPTION SELECTED>option 1<OPTION>option 2 <OPTION>option 3<OPTION>option 4 </SELECT>

<P>Reset buttons: <INPUT TYPE="reset"> <INPUT TYPE="reset" VALUE="CLEAR">

<P>Submission buttons: <INPUT TYPE="submit" NAME="submit-a"> <INPUT TYPE="submit" NAME="submit-b" VALUE="SEND">

<P>Image button: <INPUT NAME="image" TYPE="image" SRC="images/image-button.gif" ALIGN="top"> </FORM>

The X Window version of Mosaic displays this document as shown below:

Image of sample form



next up previous contents index
Next: Single-line text fields Up: Fill-out Forms Previous: The FORM element

[ITCP]Spinning the Web by Andrew Ford
© 1995 International Thomson Publishing
© 2002 Andrew Ford and Ford & Mason Ltd
Note: this HTML document was generated in December 1994 directly from the LaTeX source files using LaTeX2HTML. It was formatted into our standard page layout using the Template Toolkit. The document is mainly of historical interest as obviously many of the sites mentioned have long since disappeared.

 
Copyright © 1996-2002 Ford & Mason Ltd