HTML Forms
Text fields are one line areas that allow the user to input text.
If you want several lines you should use a
text
area instead.
SETTINGS:
Below is a listing of valid settings for
text fields:
|
HTML |
EXPLANATION |
EXAMPLE |
|
password |
One line
password field |
|
The size
option defines the width of the field. That is how many visible characters it
can contain.
The maxlength option defines the maximum length of the field. That is how many
characters can be entered in the field.
If you do not specify a maxlength, the visitor can easily enter more characters
than are visible in the field at one time.
The name
setting adds an internal name to the field so the program that handles the form
can identify the fields.
The value
setting defines what will appear in the box as the default value.
The align
setting defines how the field is aligned.
Valid entries are: TOP, MIDDLE, BOTTOM, RIGHT, LEFT, TEXTTOP, BASELINE,
ABSMIDDLE, ABSBOTTOM.
The tabindex setting defines in which order the different fields should be
activated when the visitor clicks the tab key.
AN EXAMPLE:
Look at this HTML example:
|
<html> |
And the resulting output from it:
|
|
Text areas are text fields that can span several lines.
Unlike most other form fields, text areas
are not defined with an <input> tag.
Instead you enter a <textarea>
tag where you want the text area to start and a closing </textarea>
tag where you want the area to end.
Everything written between these tags will
be presented in the text area box.
SETTINGS:
Below is a listing of valid settings for
text areas:
|
HTML |
EXPLANATION |
EXAMPLE |
|
textarea |
Text area -
several lines |
|
The cols
and rows settings are straightforward and simple.
They specify how many columns and rows you want in your text area.
The name
setting adds an internal name to the field so the program that handles the form
can identify the fields.
The tabindex setting defines in which order the different fields should be
activated when the visitor clicks the tab key.
The wrap
options are the most tricky part of text areas.
If you turn wrap off the text is handled as one long sequence
of text without linebreaks.
If you set it to virtual the text appears on your page as if it
recognized linebreaks - but when the form is submitted the linebreaks are
turned off.
If you set it to physical the text is submitted exactly as it
appears on the screen - linebreaks included.
AN EXAMPLE:
Look at this HTML example:
|
<html> |
Check boxes are used when you want to let the visitor select one or
more options from a set of alternatives. If only one option is to be selected
at a time you should use radio buttons instead.
SETTINGS:
Below is a listing of valid settings for
check boxes:
|
HTML |
EXPLANATION |
EXAMPLE |
|
checkbox |
Choose one
or more options |
|
The name
setting adds an internal name to the field so the program that handles the form
can identify the fields.
The value
setting defines what will be submitted if checked.
The align
setting defines how the field is aligned.
Valid entries are: TOP, MIDDLE, BOTTOM, RIGHT, LEFT, TEXTTOP, BASELINE,
ABSMIDDLE, ABSBOTTOM.
The tabindex setting defines in which order the different fields should be
activated when the visitor clicks the tab key.
AN EXAMPLE:
Look at this HTML example:
|
<html> |
And the resulting output from it:
|
|
Radio buttons are used when you want to let the visitor select one
- and just one - option from a set of alternatives. If more options are to be
allowed at the same time you should use
check
boxes instead.
SETTINGS:
Below is a listing of valid settings for
radio buttons:
|
HTML |
EXPLANATION |
EXAMPLE |
|
radio |
Choose one
- and only one - option |
|
The name
setting tells which group of radio buttons the field belongs to. When you
select one button, all other buttons in the same group are unselected.
If you couldn't define which group the current button belongs to, you could
only have one group of radio buttons on each page.
The value
setting defines what will be submitted if checked.
The align
setting defines how the field is aligned.
Valid entries are: TOP, MIDDLE, BOTTOM, RIGHT, LEFT, TEXTTOP, BASELINE,
ABSMIDDLE, ABSBOTTOM.
The tabindex setting defines in which order the different fields should be
activated when the visitor clicks the tab key.
AN EXAMPLE:
Look at this HTML example:
|
<html> |
And the resulting output:
|
Water |
Drop-down menus are probably the most flexible objects you can add
to your forms.
Depending on your settings, drop-down
menus can serve the same purpose as radio buttons (one selection only) or check
boxes (multiple selections allowed).
The advantage of a drop-down menu,
compared to radio buttons or check boxes, is that it takes up less space.
But that is also a disadvantage, because people can't see all options in the
menu right away.
There is a workaround for this - with the
size setting, you can customize the menu so it shows more than just one option
at a time, but when you do that - you also lose the advantage of taking up less
space.
So whatever you decide - there is always a
bonus and a price to pay.
Sometimes you may want to replace text
fields with drop-down menus. This might be because selecting from a menu is
easier than typing. But it could also be because the script that handles the
form can't interpret just any text entry.
For example, you will often be asked to
choose your state from a drop-down menu. This might be because picking it from
the menu is easier than typing the name of the state.
.
SETTINGS:
Below is a listing of valid settings for
drop-down menus:
|
HTML |
EXPLANATION |
EXAMPLE |
|
select |
Drop-down
menu |
|
Drop-down menus combine <select>
and <option>.
Both tags have an opening and a closing tag.
A typical example of the syntax would be:
|
<select> |
The <select> tag defines the
menu.
The name
setting adds an internal name to the field so the program that handles the form
can identify the fields.
The size
option defines how many items should be visible at a time. Default is one item.
The multiple setting will allow for multiple selections if present.
The <option> tag defines the
single items in the menu.
The value
setting defines what will be submitted if the item is selected. This is not
always the same as what it says in the menu. If our field was defined this way:
|
<option
value="ID">Idaho</option> |
then, in the menu it would say "Idaho" but when the form was
submitted the abbreviated "ID" would actually be sent.
You can force an item to be default
selected by adding the selected option: <option selected>
AN EXAMPLE:
Look at this HTML example:
|
<html> |
And the resulting output from it:
|
|
When a visitor clicks a submit button, the form is sent to the
address specified in the action setting of the <form> tag.
SETTINGS:
Below is a listing of valid settings for
submit buttons:
|
HTML |
EXPLANATION |
EXAMPLE |
|
submit |
Submit
button |
|
The name
setting adds an internal name to the button so the program that handles the
form doesn't confuse the button with the other fields.
The value
setting defines what is written on the button.
The align
setting defines how the button is aligned.
Valid entries are: TOP, MIDDLE, BOTTOM, RIGHT, LEFT, TEXTTOP, BASELINE, ABSMIDDLE,
ABSBOTTOM.
The tabindex setting defines in which order the different fields should be activated
when the visitor clicks the tab key.
AN EXAMPLE:
Look at this HTML example:
|
<html> |
And the resulting output from it:
|
|
When a visitor clicks a reset button, the entries are reset to the
default values.
SETTINGS:
Below is a listing of valid settings for
reset buttons:
|
HTML |
EXPLANATION |
EXAMPLE |
|
reset |
Reset
button |
|
The name
setting adds an internal name to the button so the program that handles the
form doesn't confuse the button with the other fields.
The value
setting defines what is written on the button.
The align
setting defines how the button is aligned.
Valid entries are: TOP, MIDDLE, BOTTOM, RIGHT, LEFT, TEXTTOP, BASELINE,
ABSMIDDLE, ABSBOTTOM.
The alignments are explained in the image section.
The tabindex setting defines in which order the different fields should be
activated when the visitor clicks the tab key.
AN EXAMPLE:
Look at this HTML example:
|
<html> |
And the resulting output from it:
|
|
Image buttons have the same effect as submit buttons. When a
visitor clicks an image button the form is sent to the address specified in the
action setting of the <form> tag.
SETTINGS:
Below is a listing of valid settings for
image buttons:
|
HTML |
EXPLANATION |
EXAMPLE |
|
image |
Submit
button |
|
The name
setting adds an internal name to the image button so the program that handles
the form doesn't confuse it with the other fields.
The src
setting defines the URL of the image.
The align
setting defines how the image is aligned.
Valid entries are: TOP, MIDDLE, BOTTOM, RIGHT, LEFT, TEXTTOP, BASELINE,
ABSMIDDLE, ABSBOTTOM.
The border setting defines the width (in pixels) of the border around the
image.
The width
setting defines the width of the image.
The height setting defines the height of the image.
The vspace setting defines the spacing over and under the image (in pixels).
The hspace setting defines the spacing to the left and right of the image
(in pixels).
The tabindex setting defines in which order the different fields should be
activated when the visitor clicks the tab key.
AN EXAMPLE:
Look at this HTML example:
|
<html> |
And the resulting output from it:
|
|