Mgmt 298d: E-Commerce
Web Forms Tutorial

 

How to Use the Forms Tutorial

This form is located at:  http://internal.anderson.ucla.edu/staff/sylvia.merino/forms.htm
  1. Learn the basic HTML tags from one of the suggested web tutorial sites.  You must know the difference between a "Header" section and a "Body" section!
  2. Make sure that Netscape Composer is setup to use Notepad or Wordpad as the HTML Source Editor.
  3. Alternatively, you can try using Netscape Composer's tool for inserting tags:

  4. On the menu, go to  "Insert/HTML Tag"
    In the box that opens you may type a single tag, e.g. <FORM>
    Because you can only type one tag at a time, this may be a more cumbersome process than simply using Notepad
  5. Look at the last item in this tutorial, the Form Layout, and view the source code for the form.
  6. Read how each of the form elements (text, radio buttons, etc.) was designed
  7. Design your own form by changing some of the code given here
  8. Read the explanation of CGI when the concept comes up in class
  9. When you thoroughly understand how these tags work, you can design your own from scratch!

Forms Tutorial

Table of Contents

Form Tag
Input Tags
Text
Radio buttons
Check boxes
Hidden
Password
Image
Reset
Submit
Textarea Tags
Option and Select Tags
Menus
Scrolling Lists
Form Handling: CGI and Mailto Forms
Mailto Forms
Email sample #1
Email sample #2
Form Layout
 

Form Tag

Like most HTML tags, the FORM tag is a "container" tag, i.e. the form has a beginning and ending tag to "contain" the form.

Basically, you use the FORM tag in this way:

Here are rules for what goes inbetween those tags: Here are suggestions for best use of forms: The beginning <FORM> tag actually is a little more complicated.  It also has to specify: We'll talk more about this under "Forms Handling".
 

Input Tags

There are different types of form elements.  Several of them belong in a group called "Input types."

Attributes allowed for input type form elements:

Usage: as shown below for the different types.

TEXT

Text input tags allow the reader to enter text on a single input line. When you don't include TYPE= in your input tag, HTML will assume it is the TEXT type.

Attributes allowed for Text tags:

Usage:

<INPUT TYPE="TEXT" NAME="FIRSTNAME" SIZE=30 MAXLENGTH=40>
<INPUT TYPE="TEXT" NAME="LASTNAME" SIZE=30 MAXLENGTH=40>

RADIO BUTTONS

Radio buttons indicate a list of items, of which only one can be chosen.

Rules for Radio buttons:

Usage:

<INPUT TYPE="RADIO" NAME="CLASS" VALUE="class-emba">
<INPUT TYPE="RADIO" NAME="CLASS" VALUE="class-femba" CHECKED>
<INPUT TYPE="RADIO" NAME="CLASS" VALUE="class-mba">

CHECK BOXES

Check boxes allow the user to choose from several items in a list; multiple selections are allowed.

Rules for check boxes:

Usage:

<INPUT TYPE="CHECKBOX" NAME="BROWSER" VALUE="Netscape 3.0" CHECKED>
<INPUT TYPE="CHECKBOX" NAME="BROWSER" VALUE="Internet Explorer 3.0">
<INPUT TYPE="CHECKBOX" NAME="BROWSER" VALUE="Netscape 4.0">
<INPUT TYPE="CHECKBOX" NAME="BROWSER" VALUE="Internet Explorer 4.0">
<INPUT TYPE="CHECKBOX" NAME="BROWSER" VALUE="Other">

{see email sample #1 for the emailed results from this coding}

  or, don't use VALUE, but make the NAME distinct:

<INPUT TYPE="CHECKBOX" NAME="Netscape 3.0" CHECKED>
<INPUT TYPE="CHECKBOX" NAME="Internet Explorer 3.0">
<INPUT TYPE="CHECKBOX" NAME="Netscape 4.0">
<INPUT TYPE="CHECKBOX" NAME="Internet Explorer 4.0">
<INPUT TYPE="CHECKBOX" NAME="Other">

{see email sample #2 for the emailed results from this coding}

HIDDEN

A hidden field does not appear to the user, it is "hidden" from their view.   It is generally used when a complex interactive form needs to pass variable information on from one form on to another form before passing to the CGI script.

Usage:

<INPUT TYPE="HIDDEN" NAME="FORM-URL-ID" VALUE="the-url">
 

PASSWORD

Password text fields echo what the user types with asterisks or bullets.  This allows them to feel secure typing in their password, even in a public setting.  Note: this is not an actual security measure, i.e. it does not encrypt the password before sending it on to the server!

Attributes allowed for Password tags:

Usage:

<INPUT TYPE="PASSWORD" NAME="NICKNAME" SIZE=20 MAXLENGTH=20>

IMAGE

The Image input type allows the user to submit a form by clicking on an image.

Rules for Image buttons:

Usage:

<INPUT TYPE="IMAGE" SRC="small_logo.gif" ALIGN=TOP>
 

RESET

If users make mistakes in filling out your form, they may want to completely "reset" or clear the form and start over.

Rules for the Reset button:

Usage:

<INPUT TYPE="RESET" VALUE="Clear form">
 

SUBMIT

After your users have entered information into the form, they will want to submit the information.
 
Rules for the Submit button: Usage:

<INPUT TYPE="SUBMIT" VALUE="Send Form Info">
 

Textarea Tags

With the "Textarea" tag the user will be able to type into a multi-line text field (an "area" rather than a single input line)

Attributes allowed for Textarea tags:

Usage:

<TEXTAREA NAME="COMMENTS" ROWS=20 COLS=6 WRAP="PHYSICAL">
A paragraph of default text material can be entered here.
</TEXTAREA>

Option and Select Tags

MENUS

The Select tags begin and end the list.  With the "Option" tag the user will choose from only one option within a "select" list.

Attributes allowed for Option tags:

Usage:

<SELECT NAME="Fav">
<OPTION> Vanilla
<OPTION>Chocolate
<OPTION SELECTED>Strawberry
</SELECT>

SCROLLING LISTS

Similar to menus, but the user will make a selection or multiple selections from a finite set of options.

Attributes allowed for Select tags:

Usage:

<SELECT NAME="Flavors" MULTIPLE SIZE=2>
<OPTION> Vanilla
<OPTION SELECTED>Chocolate
<OPTION>Strawberry
</SELECT>

 

Form Handling: CGI and Mailto Forms

It's relatively easy to type HTML markup tags into a web page and create the form interface.  Next comes the hard part.  The information that a user will enter into your form must be delivered somewhere.  For a truly interactive user-experience,  the information should be delivered to a server and handled by a particular script on the server that knows about the particular information coming from your web form.  Actually, it gets a little more involved:
  1. The server must be configured to receive the information from the form and know that it must pass it on to a program or script in the prescribed manner

  2. (note:  most of the big consumer ISPs, like AOL and CompuServe, do NOT allow users to even use CGI scripts; their servers are NOT configured for end-user CGI scripts)
  3. A program or script must be written that is prepared to handle (interpret) the information coming from a particular form and process it properly
  4. Form-related events may involve checking against a database, therefore even further processing is needed to couple database info to intended script responses
On Unix servers, the language used to create scripts is called Perl and the scripts are called CGI scripts.  Teaching you how to program in Perl and create CGI scripts goes beyond what we have time for in this workshop.  We can, however, also have the information delivered to an email box.  This takes no CGI script, although the data that lands in your email box may need some explanation.

MAILTO FORMS

As we said earlier in this tutorial, the beginning <FORM> tag  has two attributes: Usage:

<FORM METHOD="POST" ACTION="MAILTO:firstname.lastname@anderson.ucla.edu">
all your form programming goes inbetween the opening and closing form tags
</FORM>

Email received:

Data that a user submits via an email form will appear to be one long string.  If you look carefully, it contains all the name/value pairs for each of the form elements you created. Each name/value pair is separated from the next by the ampersand "&" character.  Additionally, some special characters get encoded.

For example, the form below submits the following type of info to my email box (all as one line, but I've broken it here):

Email Sample #1

FIRSTNAME=Michael&LASTNAME=Merino&
CLASS=class-mba&
BROWSER=Netscape+3.0&BROWSER=Internet+Explorer+3.0&BROWSER=Netscape+4.0&
FORM-URL-ID=the-url&
NICKNAME=moose&
COMMENTS=Comments+go+here&
Fav=Chocolate%A0&
Flavors=Vanilla%A0&Flavors=Chocolate%A0&
x=33&y=17

Email Sample #2

FIRSTNAME=Mike&LASTNAME=Merino&
CLASS=class-emba&
Netscape+4.0=on&Internet+Explorer+4.0=on&
FORM-URL-ID=the-url&
NICKNAME=chubchub&
COMMENTS=Comments+are+here.&
Fav=Vanilla%A0&
Flavors=Vanilla%A0&Flavors=Strawberry%A0
 
 
There are some shareware and commercial software packages available that "parse" these types of email so that you can keep customer records in a spreadsheet or database.  You would need to investigate what packages are available and would work with your particular email server and email client.


Form Layout

Note that there are two ways to give a pleasing layout to your form:
  1. Use the <PRE> tags so that the font uses FIXED rather than variable widths and you can control the exact spacing of characters
  2. Use a table to place your form elements exactly where you want them (I used this method below, with column 1 set to a width of 100 pixels)
Example form using all of the form elements discussed above:




 
FIRST NAME:
LAST NAME:
YOUR CLASS: emba   femba   mba
BROWSER(S) YOU USE: Netscape 3.0  Internet Explorer 3.0 Netscape 4.0 Internet Explorer 4.0  Other
(hidden field)
SECRET NICKNAME:
SUBMIT COMMENTS:
SINGLE FAVORITE:
FAVORITE(S):
IMAGE SUBMIT BUTTON:
REGULAR SUBMIT:
REGULAR RESET:

Send comments to:
 
Sylvia Merino
Anderson Computing & Information Services