Creating Fill-Out Forms
HTML includes about a half-dozen elements for creating fill-out form
elements. A form must begin with <FORM> and end with
</FORM>:
Code:
<form action="http://stein.cshl.org/cgi-bin/test-cgi.pl" method="POST">
Choose a Motif:
<input type="text" name="motif" value="TATTAT"> <br>
<input type="submit" name="search" value="Search!"> <br>
</form> |
Result:
The <FORM> Tag
Attributes:
- action (required)
- CGI script to submit contents of form to.
- method (required)
- Submission method. Depends on CGI script. One of:
- encoding
- Required by certain scripts that accept file uploads. One of:
- application/x-www-form-urlencoded
- multipart/form-data
<INPUT> Elements
Used for text fields, buttons, checkboxes, radiobuttons. Attributes:
- type
- Type of the field. Options:
- submit
- radio
- checkbox
- text
- password
- hidden
- file
- name
- Name of the field.
- value
- Starting value of the field. Also used as label for buttons.
- size
- Length of text fields.
- checked
- Whether checkbox/radio button is checked.
Examples:
<SELECT> Element
Used to create selection lists.
Attributes:
- name
- Name the field.
- size
- Number of options to show simultaneously.
- multiple
- Allow multiple options to be shown simultaneously.
<OPTION> Element
Contained within a >SELECT> element. Defines an option:
>option>I am an option</option>
Attributes:
- selected
- Whether option is selected by default.
- value
- Give the option a value different from the one displayed.
<TEXTAREA> Elements
Used to create big text elements.
Attributes:
- name
- name of field
- rows
- rows of text
- cols
- columns of text
- wrap
- type of word wrapping
Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Fri Oct 20 10:46:16 EDT 2000