Home HTML Guides Sitebuilder Q & A Resources Forum
J-ROBINSON.co.uk
HTML Central Amazon.co.uk - the widest choice of software at great prices


HTML GuidesControls 1

There are several different types of control that you can use in your form, although the basic concepts are the same for them all.

Each field needs a name to describe it (for example, E-Mail Address) and a value (for example feedback@htmlcentral.fsnet.co.uk). This is what you'll see in the e-mail that you receive if you're creating a mailform.

Most controls are created using the INPUT tag with several attributes. The most important is TYPE, which tells the browser what type of control to create. Coming a close second is NAME, which let's you give the field that the control represents a meaningful name.

The are also other attributes for the INPUT tag, but we'll look at those as we come accross them. And by the way, you do not need a closing input tag (</INPUT>).

Text Boxes

Text boxes are the most common type of control and you're almost certain to use at least one of them in your form. The code you'll need is:

<INPUT TYPE="TEXT" NAME="Address" VALUE="Enter your e-mail address here" SIZE="30" MAXLENGTH="40">

You can probably work out what most of the attributes are doing, but let's go through them anyway...

NAME is the field name - this must be unique within the form, so you can't have two fields with the same name. VALUE is the default value of the text box, although you can leave this attribute out if you want it to be blank. The SIZE attribute controls the width of the box on the screen, while MAXLENGTH (optional) sets a limit on the number of characters that can be entered.

More Text Boxes

Text boxes are fine for short pieces of information, but they're not too great for long sentances. Enter the TEXTAREA control, one of the few controls that don't use the input tag.

<TEXTAREA NAME="Comments" ROWS="5" COLS="40" WRAP="VIRTUAL">Enter your comments here</TEXTAREA>

You can use the ROWS and COLS attrbutes to control the size of the box. The WRAP attribute controls how the text wraps - you'll normally use VIRTUAL (as shown) but you can turn text wrapping off if you want to be setting this attribute to OFF.

Finally, notice that the TEXTAREA tag requires a closing tag. Any text you put between the tags will appear in the box as a default value.

Hidden Fields

Hidden fields let you pass data to your form handler (CGI script) without the user having to enter it, or even see it. Most CGI scripts require you to include some hidden fields to tell it how to work - for example, the script may require a field named REDIRECT to be set to the URL of the page that the browser should display after the form is submitted.

You can also use hidden fields for your own purposes - maybe to tell you what page on your site the form was submitted from.

Hidden fields use the input tag and can be positioned anywhere in your form - the user will not even know that they exist.

<INPUT TYPE="HIDDEN" NAME="REDIRECT" VALUE="http://www.mysite.com/thanks.html">

If your using a hidden field to supply data to your CGI script, make sure that you get the field name exactly correct, including case, or the script will not notice it.

HTML Central Home
    HTML Guides
        Forms

< 1 | 2 | 3 | 4 >

Search:
 
Search facility provided by Atomz.com.
HTML Guides: Click here for HTML Guides index.

HTML Central Home
    HTML Guides
        Forms

< 1 | 2 | 3 | 4 >

Navigation Bar
Please send any comments, questions or complaints via this form
HTML Central is part of j-robinson.co.uk
© James Robinson 2001

Valid HTML! Valid CSS! Labelled with ICRA