So, You Want A Form, Huh?

by Joe Burns, Ph.D.

Good idea. It really looks professional when you allow net surfers to fill in information right to your page rather than using a "mailto:" command. And looks are about it. A form does basically what email does - it sends information.

Please be advised that this tutorial will work on Netscape style browsers and MSIE 4.0 browsers only. The form commands will work on Explorer browsers 3.0 and below, but will not act as a guestbook in the same way they will in Netscape and MSIE 4.0. If you use the format below with a lower version of MSIE, you won't get any errors, just a basic email box will pop up. -- Joe

Use these to jump to a particular item - or read it all!

[The First Step][The Text Box][Text Area Box][The Radio Button]
[The Check Box][ The Pop-Up Box][Send and Reset Buttons]



FYI: The form page outlined below is very basic. It will create a guestbook for you and it will send information to you. There are a bunch of extra commands that you can attach to these form deals. They will be covered in the Guestbook Page. There you'll find ways to post a subject line, attach to a CGI, get rid of all those goofy extra characters, and more. But I would suggest you read this first before attacking the Guestbook tutorial.

The First Step

The first thing you must tell the computer is that you are starting a form, and what you want done with the form data. The command to alert the computer is:

<FORM METHOD="POST" ACTION="mailto:your email address">

Notice the command did three things:
  1. It told the computer a FORM was starting.
  2. It stated the METHOD of dealing with the form is to POST it.
  3. And the data should be posted to your email address through the "mailto:" ACTION.


Remember: you will need to put your email address immediately after the "mailto:" without a space!! This is where the results of the form will be sent.

That's nice and simple. Now that the computer knows a form has begun, it's looking for any one of a number of form styles to deal with. I will go over five here; TEXT, TEXT AREA, the RADIO BUTTON, the CHECKBOX, and the POP-UP BOX. These are by far the most used on the WWW. Also, I will go over the creation of buttons that send the form to the "mailto:" address or clears the form.


BOXES FOR ENTERING TEXT



The Text Box

This is a basic long box that allows for one line of text. When placed on a page, your reader will be able to write in information such as their name or their email address. Here what a text box looks like:

Go ahead. Write something in it. It works. You may have to use your mouse pointer and click on the box to activate it - but it works. If this is your first time making forms, you might think that the box above is a .gif or a .jpeg. Not so. The box is placed on the page through an HTML command, not as an image. The command to place it on the page is this:

<INPUT TYPE="text" NAME="name" SIZE="30">

There are three parts to the command. Here's what they are and what they mean:


2. The Text Area Box

This is a larger box, like the one above, that allows your reader to write something. The difference between the Text Box (above) and the Text Area is that the Text Box only allows for one line. The Text Area, however, is much larger and will allow for as many words as you want.
Here's a Text Area Box:

Neat, huh? Again, go ahead and write in it. It'll work. You may have to click on the box to activate it. Here's the command that made it appear:

<TEXTAREA NAME="comment" ROWS=6 COLS=40></TEXTAREA>

Please note that the TEXTAREA requires a </TEXTAREA> command whereas the TEXT BOX command above did not.

Just as before...here are its parts and what they mean:


Input Buttons



The Radio Button

This is a neat little deal that places a circle on the page. That circle is active and a reader can use the mouse to click on it. When the radio button is chosen, it darkens. Here are three radio buttons:

- -

Go ahead. Click on them. I know you're dying to. I have three of them there to prove a point. The point is that radio buttons are a one choice deal only. When you use radio buttons, only one can be checked. When another is checked - the first one gives up its selection. Go ahead - try it.

Neat, huh? But why are they called radio buttons?!?! The reason is that they act as the radio buttons used in older car radios. When you pushed one, the dial moved. When you pushed another, the first choice was dropped and the dial moved again. You're probably too young to remember. It was back when AM only was a big selling radio, back before dirt. (Man, I'm old.)

Here's the command to place a radio button on your page.

<INPUT TYPE="radio" NAME="heading of button" VALUE="button name">

You see - the TYPE in the command is "radio." The command is long, but it's not that difficult to understand. Here are its four parts and what they mean:

Why on earth would I want to label all those??

Remember that this is going to be sent to you through the mail. You will have to be able to read what the person chose. Say you had a guestbook with a section of radio buttons that ask which page the user is signing in from. Your "NAME" in the command might be "signing_in_from." Then each of the radio buttons is assigned the "VALUE" of each of your pages. Let's say a person chooses the radio button assigned to your home page. That button's VALUE might be, "home_page."

THUS...when the form arrives to you, the email would read:

"signing_in_from_ home_page"

Pretty darn slick, huh?


2. The Checkbox

The checkbox is an exact clone of the radio button except for two distinct features:
Here are a few checkboxes:

- - - -

Go ahead. Click around a bit. You'll note that just one or every one can be chosen. This checkbox is basically a fancy radio button. Here's the command that placed the checkbox on the page:

<INPUT TYPE="checkbox" NAME="Signing_from" VALUE="Joes_page">

Each of the items mean the same as above so there's no need to go over them again. Please note, however, the TYPE is now "checkbox" instead of "radio."

Remember that when the text from a check box arrives at your email box, more than one can show up. With radio buttons, only one item under the NAME heading will arrive. With checkboxes, every item can be checked, thus every item can arrive.

I like radio buttons much more than checkboxes. The reason is that the radio button forces a choice. Checkboxes invite people to just check everything every time. That can waste your time reading through it all. I like to make a one choice deal. It's easier on me and if people want to leave more info, there's always the TEXT AREA box for that purpose.


The Pop-Up Box

I LOVE these Pop-Up boxes, but I don't use them too often. I like to have all the items people can choose out in the open. The Pop-Up box, unless clicked on, only shows one item. But, this is your form and you can do anything you wish. Here's a Pop-Up box. You have to click on it to see all the choices. This one is for people to choose their favourite colour:

Here are the commands that placed the Pop-Up box on the page:

<SELECT NAME="Favourite_Colour" SIZE="1">
<OPTION SELECTED>Blue
<OPTION>Red
<OPTION>Yellow
<OPTION>Green
<OPTION>Black
<OPTION>Orange
<OPTION>Purple
</SELECT>

Although this looks a little bit more involved - it really isn't. It's the same thing again and again. Here are the parts and what they mean:


     People write and ask if it's possible to make the above pop-up box a series of links for people to choose and then go to. With HTML alone, it isn't possible. Using a Java Applet along with the code - it is. Here's the tutorial:
So You Want A Pull-Down Java-Driven Link Menu, Huh? That's a long title.


Send and Reset Buttons



     Well, now that the you have placed all the form items you want on your page, you need a way to have the results sent to your email box (or where ever you said this would go in the original form statement).

This may be the easiest of all the items I've shown on this page. Here are the buttons:

Please do not use the buttons. They are active and will attempt to work - however I have put in a false email address so I don't fill my own box with email from this tutorial. You're just going to get scolded!


And here are the commands to put the buttons on the page:

<INPUT TYPE="submit"><INPUT TYPE="reset">

Easy, huh? Now when you click on the buttons, the form will enact the ACTION you noted in the original FORM command. Here it would have been mailed to my email box. (or not in this case)

Finally!

Make sure you end your page with this:

</FORM>


That's a beginning on forms, but there is so much more you can do than what I have here. There are forms you can connect to other CGI's (Common Gateway Interfaces), databases, or other data collection devises. All I wanted to do here was give you a very basic, very easy form for you to use on your web pages.

[The First Step][The Text Box][Text Area Area Box][The Radio Button]
[The Check Box] [The Pop-Up Box][Send and Reset Buttons]