Division of Information Technology
Web Publishing @ SFSU
Forms

What Forms can Help you do Forms allow WWW browsers to interact with servers. Forms can display empty text boxes, user selectable menus, buttons and more. Most forms include a Submit and Reset button. Forms can be used to:
  • Send E-mail
  • Fill out online surveys
  • Take online tests
  • Search databases
  • Enter data in databases
  • Validate users
  • And much more....
Form Components There are two parts to any functional form.
  • The HTML document containing the HTML form codes, used to design the form's screen layout.
  • A <FORM METHOD=POST ACTION="URL"> that references either an mailto:email@address or a template file. See CGIEMAIL for directions on how to setup a template file. When a mailto URL is used the information filled out in the form is E-mailed to the recipient specified. When a script URL is used the information is sent to a CGI-BIN program that interacts with the information collected.
Sample Code FORM tag
All form code (such as the sample code below) must be placed between the FORM tags.

HTML Code

<FORM METHOD=POST ACTION="URL of script to handle form">
</FORM>
Drop Down Menu

HTML Code

Year:
<SELECT NAME="year">
<OPTION VALUE="1999">1999
<OPTION VALUE="2000">2000
<OPTION VALUE="2001">2001
</SELECT>

How it looks in the form

Year:
Checkbox

HTML Code

<P> Are you a student, staff or faculty? [Check all that apply]
<BR><INPUT TYPE="CHECKBOX" name="group" value="student" CHECKED>Student
<BR><INPUT TYPE="CHECKBOX" name="group" value="staff">Staff
<BR><INPUT TYPE="CHECKBOX" name="group" value="faculty">Faculty

How it looks in the form

Are you a student, staff or faculty? [Check all that apply]
Student
Staff
Faculty

Radio button
<P>Please select the term?
<INPUT TYPE="RADIO" name="term" value="spring">spring
<INPUT TYPE="RADIO" name="term" value="summer">summer
<INPUT TYPE="RADIO" name="term" value="fall">fall
<INPUT TYPE="RADIO" name="term" value="winter">winter

How it looks in the form

Please select the term? spring summer fall winter
Fill-in (2 examples)
<P> What is your major? (optional)
<INPUT TYPE="TEXT" name="major" value=" " size=30>
<P>What is your E-mail?
<INPUT TYPE="TEXT" name="required-email" value="" size=30>

How it looks in the form

What is your major? (optional)
What is your E-mail?

Textbox
<P> Comments:
<textarea name="comments" ROWS=4 COLS=60></textarea>

How it looks in the form

Comments:

Submit and Reset buttons

The submit button performs the action specified in the <form> tag. The reset button clears any information the user has entered. The text on the submit and reset buttons can be modified by changing their value name.

<P> <input type="submit" value="Submit">
<input type="reset" value="Start Over">

How it looks in the form


This is the resulting code and form from the example above:

HTML Code

<form METHOD="POST" ACTION="URL of script to handle form">
Year: <SELECT NAME="year">
<OPTION VALUE="1999">1999
<OPTION VALUE="2000">2000
<OPTION VALUE="2001">2001
</SELECT>
<P> Are you a student, staff or faculty? [Check all that apply]
<INPUT TYPE="CHECKBOX" name="group" value="student" CHECKED>Student
<INPUT TYPE="CHECKBOX" name="group" value="staff">Staff
<INPUT TYPE="CHECKBOX" name="group" value="faculty">Faculty
<P> Please select the term?
<INPUT TYPE="RADIO" name="term" value="spring">spring
<INPUT TYPE="RADIO" name="term" value="summer">summer
<INPUT TYPE="RADIO" name="term" value="fall">fall
<INPUT TYPE="RADIO" name="term" value="winter">winter
<P> What is your major? (optional)
<INPUT TYPE="TEXT" name="major" value="Accounting" size=30>
<P> What is your E-mail?
<INPUT TYPE="TEXT" name="required-email" value="" size=30>

<P> Comments:
<textarea name="comments" ROWS=4 COLS=60></textarea>
<P> <input type="submit" value="Submit">
<INPUT TYPE="RESET" VALUE="Start Over">
</form>

Here is how the form will appear in a web browser

Year:

Are you a student, staff or faculty?
Student
Staff
Faculty

Please select the term?
spring summer fall winter

What is your major? (optional)

What is your E-mail?

Comments:

3 basic CGI's available at SFSU CGIEMAIL
Form data submitted via the web with results sent to a specified E-mail address.

CGIFILE
Form data submitted via the web with results saved to a text file. The data can be imported into a database or spreadsheet without retyping.

PADFORM
Prepare a formatted form for the user. The information the user enters the form is placed into a preformatted page for printing, rather than sending the form results via E-mail. This is also a good tool to use when a submitted form will require a signatur e.

For More Information An Instantaneous Introduction to HTML Forms
Yahoo's Forms Resources

About | Getting Started | Create | Publish | Enhance | Advertise | Maintain
Index | Glossary | Software | For more Information


SFSU Home   Search   Need Help?  

1600 Holloway Avenue, San Francisco, CA 94132 (415) 338-1111
Last modified February 11, 2008 by the Web Team