A Brief Introduction to HTML Forms
Forms allow HTML documents to become interactive. Users can input information which can be manipulated locally or sent to a server.
In particular, forms act as the front-ends to CGI scripts and Javascript.
As such, before one can begin to use CGI, it is useful to get a handle on Web forms. This page briefly introduces the basics of Web forms.
The Form Tag
As with all HTML coding, forms are created using tags.
The first, and most important, is the <FORM> tag.
The <FORM> tag requires both an opening and a closing tag, and at a minimum requires the action attribute. This action attribute specifies what the form should do with the data when it is submitted. For the most part this will be the URL of some CGI script, but other values are possible.
So, here is what it looks like in your HTML document:
<FORM action="http://www.gslis.utexas.edu/cgi-bin/test.cgi">
Insert lots of neat form elements here, including a submit button
</FORM>
The Input Tag
Within those opening and closing form tags, you can put a variety of input entities or elements. Each form element is created using a tag and usually several attributes. We will proceed from the relatively simple elements to the somewhat complex. The simplest elements, appropriately enough, are created using the <INPUT> tag. Unlike the <FORM> tag, <INPUT> does not need a closing tag, but it almost always requires at least two attributes.
First, the type attribute determines what type of input element will be created. Second, the name attribute gives the input element a name. How we define these two attributes affects the behavior and further options of our input element.
It is important to understand what the name attribute does. It gives form elements a unique identifier. When our form is passed to a CGI script we access the values from the form based on these names. These names can be anything we like, but it is useful to use a short description of the value being collected. Thus, if we are getting someone's age, it only makes sense that the name of that form element be "age." The use of the name attribute should become clearer as we proceed.
Last modified: Thu Jun 4 13:42:27 CDT 1998