Forms are used to gather
information from a viewer and make a site more
interactive. Typical kinds of forms are guestbooks,
questionaires, contests, order forms,
etc.
Forms can be
a headache to code in plain text, and it is often
much more expedient to use a WYSIWYG (What You See Is What
You Get) editor
The Basics and
Concepts
All forms must start with the <FORM> tag and end
with the </FORM> tag.
There are two very important attributes, or
2ndtier tags that beloing the the <FORM> tag.
METHOD - this attribute can have values of either
"GET" or "POST". These are commands that tell
the browser how to communicate with your server. Most search
engines use "GET" because they want to query data from a
pre-established index, and most questionaire-type forms use
"POST" because they are collecting information and posting
it to the server.
ACTION - this attribute tells the browser what
CGI script to run to process the data. The value for this
attribute would be either the URL to the CGI script, or a
mailto: function which will send the form data directly to
an e-mail address. The latter option is generally easier for
most beginners and those using free web space, or other
servers which do not allow CGI-BIN access. (AOL, PRODIGY,
NETCOM, AT&T, and many others DO NOT allow CGI-BIN
access to users.)
The "ACTION" attribute in the
<FORM> Tag is set to MAILTO:. This will send an
e-mail to the e-mail address specified.
The first INPUT is a "TEXT" field.
The "NAME" attribute is simply for your own purposes
when viewing form responses.
In that same field, the "VALUE"
attribute, set to "John Doe", is simply a default.
The second INPUT is a "SUBMIT" or a
submit button. The "VALUE" attribute in both this
button, and the RESET button, is the text that will
appear in the button.
Form
Elements
There are
very many INPUT types that can be used in HTML forms. For all
types, the coding is as follows: <INPUT="Type">. The
"Type" option is the name off the field type you wish to put
in your form.
Element
Description & HTML
Code
Text Fields
Text fields are used the
most commonly used field in forms.
Drop-down menus are
very commonly used in forms. They are a good way to
arrange large numbers of options. They are slightly
different in coding from the other form fields because
they do not use the <INPUT TYPE=""> tag.
There is another kind of
drop-down menu that is coded almost exactly the same,
but it allows for multiple selections. The only
difference is the "MULTIPLE" option in the
<SELECT> tag.
Text areas, like drop-down
menus, do not use the <INPUT TYPE=""> tag. Text
areas are multiline text fields.
You've seen several examples of forms. If you want to you can test you knowledge her, but you will have to code the minimum HTML needed for a web page plus the code for the form you want to try: