Logobeben.jpg (28941 bytes)

Sandra's Backyard home

HTML tutorials
©2003 by Kati Petit


Forms:

Text Boxes & Areas
Radio Buttons/Check Boxes
Drop-down Boxes
Send & Reset

 

Forms, like the one you'll see on my Q & A Page, are extremely simple to create--but getting them to actually do something useful is another story altogether. Fact is, there really isn't much you can do with a form using straight HTML.

You can create the elements (text boxes, radio buttons, etc.), but you can't really get them to do much without using CGI, a database, or some nifty JavaScript. If you want to learn about the JavaScript option, I'll have a tutorial up on that sometime in the (hopefully) near future.

If you don't want to go through that hassle, my suggestion is this: find a site that will do all of the work for you. Bravenet is a good choice (I've used them a lot, and they've proven to be fairly reliable.), but there are others. Usually, you can use a site like this to create a form, and have it send you an e-mail whenever someone fills it out.

Now, if you've already gotten a form from Bravenet or someplace like it, and you just want to customize it... well, that I can help you with.

This is what you can find in this section: Text Boxes & Areas / Radio Buttons vs. Check Boxes / Drop-down Boxes / Send & Reset

Text Boxes & Areas

If you want a spot on your form for your visitors to enter text, you have a couple of options. If you just want them to put in their name, or the subject of their message, the better choice is the text box:

Go ahead, enter some text. This is how I did it:

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

It's fairly simple. The INPUT TYPE just tells the browser you want a text box. The NAME is the name of that text box--if you have more than one text box on a page, it's a good idea to name them separate things. SIZE... well, I think you can figure that one out yourself.

If, on the other hand, you want your visitor to be able to enter text of a paragraph or more, a text area is far better:

Here's the code:

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

Notice you have to close this tag with </TEXTAREA>, whereas the text box didn't require a closing tag. ROWS and COLS simply denote the size of the text area--play around with it until it's the size you want.

^ top

Radio Buttons vs. Check Boxes

Alright, say you want your visitors to vote on something using your form. For instance:

Is my site the coolest ever?

Is my site cooler than all others?

Neat, eh? This is how you do it:

<INPUT TYPE="radio" NAME="radiobutton" VALUE="coolest">

Don't ask me why they're called "radio buttons", they just are. The input type, obviously, tells the browser that this is a radio button, not a text box. NAME is the category for the buttons, all the radio buttons dealing with one subject should have the same name. For instance, if I wanted two sets of radio buttons on my page, one for voting about the coolness-level of my site, and another for voting about whether it was pure genius or super-genius, the first group's name might be "cool" and the second group's name might be "genius_level". The VALUE denotes the different options on the poll, in the example I showed above, one for "coolest ever" and one for "cooler than all others".

But WAIT! What if you think my site is the coolest ever AND cooler than all others?! You can only choose one of the two using radio buttons... looks like this is a job for checkboxes!

Is my site the coolest ever?
Is my site cooler than all others?

<INPUT TYPE="checkbox" NAME="check1" VALUE="coolest">

The code is the same as before, except now the input type is "checkbox". Now you can pick both, and all is right with the world.

^ top

Drop-down Boxes

My site is:  

Drop-down (or pop-up, they're actually called both... go figure) boxes are relatively simple to create, don't let the length of the code scare you.

<SELECT NAME="My_site_is" SIZE="1">
<OPTION SELECTED>
The best!
<OPTION>
Very cool!
<OPTION>
Spectacular!
<OPTION>
Fantastic!
<OPTION>
The coolest!
<OPTION>
Awesome!
<OPTION>Astounding!
</SELECT>

SELECT just says that this is a select (drop-down) box, and SIZE just tells it what size the box should be. OPTION SELECTED is the option that is first visible, and the others are, quite obviously, other options. Don't forget to finish it off with the </SELECT> tag!

^ top

Send & Reset

Ok, these are pretty necessary for any form. If you're using Bravenet or any other service, they should already be part of the form, but in case you should need them for some reason, the code is:

<INPUT TYPE="submit">

For "Submit" or "Send" and

<INPUT TYPE="reset">

For "Reset" or "Clear".

See? You can make them say whatever you want by adding "VALUE", like so:

<INPUT TYPE="submit" VALUE="Don't you dare click me!">

If you want the buttons to be colorful, you can use the STYLE property:

<INPUT TYPE="submit" VALUE="Don't you dare click me!" STYLE="background-color:#cc99cc">

And you can even make them look flat, rather than 3D, by changing the border:

<INPUT TYPE="submit" VALUE="Don't you dare click me!" STYLE="background-color:#cc99cc; border: 1px solid white">

And there you have it.

^ top

Back to HTML tutorials