Forms

Forms are a bit more complicated and strict than what we've been doing up til now. You've probably signed a guestbook at least once, right? That's a form. The most common you'll find on personal pages are guestbooks and mailto forms. Guestbooks you don't need to worry about, there are plenty of people willing to do that for you. Mailto forms send the information from the e-mail address of the person filling out the form to your e-mail address. Some website providers will let you submit a form through their server instead, and if you get a provider that does that, I'd recommend it. But we'll get back to that later.

The first part and last part of a form look like this:

<FORM METHOD="post" ACTION="mailto:your@email"> </FORM>

What it means: There are several different ways to collect information with a form. Here's the simplest:

Text box:
What's your name? <BR>
<INPUT TYPE="text" NAME="mynameis">

Here's what it means: Here's what it looks like:
What's your name?


You can make a box for messages.

Text area:
Have you got anything to tell me? <BR>
<TEXTAREA NAME="comments" ROWS="13" COLS="50">
</TEXTAREA>

Here's what it means: Here's what it looks like:
Have you got anything to tell me?

You can insert your own text into the box if you feel like it:

Have you got anything to tell me? <BR>
<TEXTAREA NAME="comments" ROWS="13" COLS="50">
No, not really.. </TEXTAREA>

Becomes:
Have you got anything to tell me?


Do you want to offer a bunch of options? Then you probably want this:

Drop-down list:
What's your favorite color?
<SELECT NAME="favcolor">
<OPTION>red
<OPTION>orange
<OPTION>yellow
<OPTION>green
<OPTION>blue
<OPTION>purple
<OPTION>brown
<OPTION>black
<OPTION>white
<OPTION>gray
<OPTION>plaid
</SELECT> <BR>

What it means:
Here's what it looks like:
What's your favorite color?
As you can see, clicking on the arrow bring up the entire list, which can then be chosen from.

If it's just a yes-or-no question, or you want to allow visitors to select more than one option, this is the answer:

Checkboxes:
I enjoy (check all that apply): <BR>
<INPUT TYPE="checkbox" NAME="sports"> sports
<INPUT TYPE="checkbox" NAME="movies"> horror movies
<INPUT TYPE="checkbox" NAME="tv"> television, baby!
<INPUT TYPE="checkbox" NAME="books"> reading
<INPUT TYPE="checkbox" NAME="weird"> talking to myself <BR>

Becomes:
I enjoy (check all that apply):
sports horror movies television, baby! reading talking to myself
If you want about the same kind of look, but you don't want more than one answer, then try:

Radio buttons
How many toes do you have? <BR>
<INPUT TYPE="radio" NAME="toes" VALUE="less"> less than eight
<INPUT TYPE="radio" NAME="toes" VALUE="8"> 8
<INPUT TYPE="radio" NAME="toes" VALUE="9"> 9
<INPUT TYPE="radio" NAME="toes" VALUE="10"> 10
<INPUT TYPE="radio" NAME="toes" VALUE="11"> 11
<INPUT TYPE="radio" NAME="toes" VALUE="12"> 12
<INPUT TYPE="radio" NAME="toes" VALUE="13"> 13
<INPUT TYPE="radio" NAME="toes" VALUE="14"> 14
<INPUT TYPE="radio" NAME="toes" VALUE="15"> 15
<INPUT TYPE="radio" NAME="toes" VALUE="more"> more
Here's what it means: Here's how it looks:
How many toes do you have?
less than eight 8 9 10 11 12 13 14 15 more
Submit button:
<INPUT TYPE="submit">
This is the button that will send the contents of the form on their way.
It looks like this:
Reset buttom:
<INPUT TYPE="reset">
This button clears the entire form. It's not really necessary.
It looks like this:
You can change what these buttons say with the VALUE command:
<INPUT TYPE="submit" VALUE="Done!"> <INPUT TYPE="reset" VALUE="Oops!">
Becomes:

The problem is that mailto forms are no longer supported on most browsers. Here are some alternatives.

If the place hosting your site that it supports forms, take the address they give you and put it into the FORM tag in place of your e-mail address. This is how you'd do one on Geocities:

<FORM METHOD="POST" action="/cgi-bin/homestead/mail.pl?member_name">
(Where member_name is the name you use to sign on to Geocities.)
What's your name? <BR>
<INPUT TYPE="text" NAME="name"> <BR>
Your e-mail address? <BR>
<INPUT TYPE="text" NAME="email"> <BR>
Do you have a page? <BR>
<INPUT TYPE="checkbox" NAME="yes"> yes <BR>
<INPUT TYPE="checkbox" NAME="no"> no <BR>
If yes, what's it called? <BR>
<INPUT TYPE="text" NAME="page"> <BR>
If no, what are you planning for the one you're learning to build? <BR>
<INPUT TYPE="text" NAME="plan"> <BR>
Any questions? <BR>
<TEXTAREA NAME="comments" ROWS="9" COLS="45">
</TEXTAREA> <BR>
</FORM>

And here's how it looks:
What's your name?

Your e-mail address?

Do you have a page?
yes
no
If yes, what's it called?

If no, what are you planning for the one you're learning to build?

Any questions?



This form will actually work.. you can send your answers right to me!

If your host doesn't support forms, here are some places that will let you use their servers for the same purpose:
Bravenet
Response-O-Matic
CGI For Me
But always check your host first.

Back to the tutorial menu