Basic Forms

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 e-mail address through the "mailto:" ACTION.

 


Remember you will need to put your e-mail 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 DROP-DOWN  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 e-mail address. Here's 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:

 

 


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 have 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 arrived to you, the e-mail would read:

"signing_in_from_ home_page"
 


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 checkbox arrives at your e-mail 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 if you have to read 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 Drop-Down Box

The Drop-Down box, unless clicked on, only shows one item. Here's a Drop-Down box. You have to click on it to see all the choices. This one is for people to choose their favorite color:

 

Here are the commands that placed the Drop-Down box on the page:

<SELECT NAME="Favorite_Color" 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:


Submit 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 e-mail box (or wherever 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 e-mail address so I don't fill my own box with e-mail 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 e-mail box (or not, in this case).

Finally!

Make sure you end your page with this:

</FORM>