Assignment For HTML Prelims
Assignment For HTML Prelims
??
pressed my button!
see the wonderful things that can happen by clicking, selecting,
and typing in fields, and more clicking!
28a. Forming Forms
</form>
We will talk more in the next lesson about the meaning of the options in the <FORM> tag. For now think of the value for
ACTION=... as something that tells the browser the location of a script or program that will process the data sent by the browser
via the selections in the form. The two values for METHOD=..., POST or GET define one of two ways the data from the form is
sent to the program that will process the data.
Now we will review the different form elements you can use. All of the elements inside the <FORM> tags can send some
information about their contents and whether or not they have been activated by the web page viewer. Each element includes a
defined "type" plus a unique indentifying name for that element. When the form data is sent to the web server, each element sends
its name and its current state or value.
Text Input Elements (type="text")
... are used to create one line fields that viewers can type text. The default width is 20 characters, and you can create fields of other
sizes by the value in the size option. You can limit the number of characters by the value of the MAXLENGTH option. Text input
fields will be empty when the page loads, unless you provide an initial text string for its VALUE option.
A text field named "text1" that is 30 characters wide.
<input type="text" name="text1" size="30">
A text field named "text2" that is 30 characters wide but will only accept 20 characters.
<input type="text" name="text2" size="30" maxlength="20">
A text field named "text3" that is 40 characters wide with default value.
<input type="text" name="text3" size="40" value="We are not
alone">
Password Input Elements (type="password")
... are exactly the same as text input elements, except that when the viewer types in, they see "bullet" characters rather then the letter
they are typing. Password text is scrambled during transmission and then unscramble when the form data is received at the server
end. See the difference between typing in the fields below and the ones in the previous section.
http://www.mcli.dist.maricopa.edu/tut/tut28a.html (2 of 10) [1/2/2002 4:10:35 PM]
We are not alone
28a. Forming Forms
A password field named "pass1" that is 30 characters wide.
<input type="password" name="pass1" size="30">
A password field named "pass2" that is 30 characters wide but will only accept 20
characters.
<input type="password" name="pass2" size="30"
maxlength="20">
A password field named "pass3" that is 40 characters wide with default value.
<input type="password" name="pass3" size="40" value="We are
not alone">
Text Area Input Elements (type="textarea")
... are text fields that have more than one line and can scroll as the viewer enters more text. The tag options define the size of the
field by the number of rows and character columns. By adding the option WRAP=VIRTUAL, the text entered will automatically wrap
at the right hand side of the field. You can also include default text to appear in the field.
A textarea field named "comments" that is 45 characters wide and 6 lines high.
<textarea name="comments" rows="6" cols="45" wrap="virtual">
The first time I ever saw a web page, I thought....
(continue)
</textarea>
Radio buttons (type="radio")
... are sets of buttons that are linked so that only one among button in each sets is selected at a time; if you click one button, the
others in the set are automatically de-selected. A set of radio buttons is defined by providing them the same name. The value sent in
the web form is the value of the radio button that was last selected. Adding the option CHECKED to one of the buttons in a set will
make that button highlighted when the page loads.
http://www.mcli.dist.maricopa.edu/tut/tut28a.html (3 of 10) [1/2/2002 4:10:35 PM]
The first time I ever saw a web page, I thought....
(continue)
28a. Forming Forms
4 radio buttons with default selection
<input type="radio" name="food" value="hotdogs" checked>
hotdogs are my favorite food<br>
<input type="radio" name="food" value="hamburgers"> i like
hamburgers<br>
<input type="radio" name="food" value="steak"> steak is
tasty<br>
<input type="radio" name="food" value="beans"> beans are for
veggie-lovers<br>
hotdogs are my favorite food
i like hamburgers
steak is tasty
beans are for veggie-lovers
3 radio buttons with no default selection
<input type="radio" name="spread" value="ketsup"> ketsup<br>
<input type="radio" name="spread" value="mustard">
mustard<br>
<input type="radio" name="spread" value="mayo">
mayonnaise<br>
ketsup
mustard
mayonnaise
NOTE: See how the two sets of radio buttons, one named "food" and the other named "spread" operate
independently from each other.
Check Boxes (type="checkbox")
...are similar to radio buttons, but are not affected by other buttons, so you can have more than one in a group checked at a time.
Note that every checkbox has a unique name. If there is no check in the box, clicking it will place an X or a check mark there. If the
box is checked, clicking it again will remove the mark. The value sent in the web form is the value of the checkbox if it was
selected; otherwise the value will be empty. Adding the option CHECKED to one of the buttons in a set will make that button
highlighted when the page loads.
4 check boxes with default selections
<input type="checkbox" name="food1" value="hotdogs" checked>
hotdogs are my favorite food<br>
<input type="checkbox" name="food2" value="hamburgers"> i
like hamburgers<br>
<input type="checkbox" name="food3" value="steak" checked>
steak is tasty<br>
<input type="checkbox" name="food4" value="beans"> beans are
for veggie-lovers<br>
hotdogs are my favorite food
i like hamburgers
http://www.mcli.dist.maricopa.edu/tut/tut28a.html (4 of 10) [1/2/2002 4:10:35 PM]