Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

Table of Contents Home Page Web Taming's Free 'Net ToolsSite Search Table of Contents

Learning HTML: Forms

Forms are a bit more complicated than what we've been doing up till 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 guest books and mailto forms. 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 of using mailto:.

<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:

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 SELECTED>red
<OPTION>orange
<OPTION>yellow
<OPTION>green
<OPTION>blue
<OPTION>purple
<OPTION>brown
<OPTION>black
<OPTION>white
<OPTION>gray
<OPTION>plaid</OPTION>
</SELECT><BR>

Here's what it means:

Here's what it looks like:

What's your favorite color?

As you can see, clicking on the arrow will 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 use:

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

Here's what it looks like:

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" CHECKED> 10
<INPUT TYPE="radio" NAME="toes" VALUE="11"> 11
<INPUT TYPE="radio" NAME="toes" VALUE="12"> 12
<INPUT TYPE="radio" NAME="toes" VALUE="more"> more

Here's what it means:

Here's what it looks like:

How many toes do you have?
less than eight 8 9 10 11 12 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 button:

<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 supports it's own scripts, take the code snippet they give you and put it into the FORM tag in the ACTION attribute. This is how you'd do one on Tripod:

<FORM METHOD="POST" action="/bin/script_library/form_handler_mail">
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
<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>
<INPUT TYPE="submit" VALUE="Go for it!">
<INPUT TYPE="reset" VALUE="Dang! Let me start over!"><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. I replaced the Tripod code with my server's FormMail code so 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:

And here's a link to the home of FormMail Matt's Script Archive

Jump to top[Top]


 [Prev] Previous Chapter | Home | Up | Next Chapter  [Next]


Send feedback and kudos to: peterconrad@hotmail.com
Copyright © 2004 by Web Taming . All Rights Reserved.
For more attractions please visit my Personal Pages on Planet Tripod.