HTML and CSS Reference
In-Depth Information
EXPLANATION
1
A JavaScript function called
check()
is defined. It takes one parameter, a reference
to a form. Instead of
f
, the form could also be referenced as
document.forms[0]
or
document.formchbox.
2
A
for
loop is entered to go through each of the checkboxes in the form. The name
of the checkbox object is
topping
. The
length
property refers to how many check-
boxes were defined. After all of the checkboxes have been inspected, the loop exits.
3
If the checkbox element, called
topping[i]
, is checked, the
check
property has a
value
true
; otherwise
false
.
4
A string called
str
is assigned the value stored in the checkbox, and for each box
that is checked, its value will be appended to the string.
5
After all of the checkboxes have been tested, their values will be found in the
str
variable. These values are assigned to the text area box, called
order
.
6
A function, called
OK()
, is defined. Its purpose is to confirm that the user is ready
to submit his or her order.
7
If the user clicks OK in the confirmation box, the checkbox's
submit()
method is
invoked. Otherwise, nothing happens.
8
The HTML form called
formchbox
is defined.
9
The input type is a checkbox, named
topping
. Each of the checkbox choices is cre-
ated for this form.
10
An HTML text area, named
order
, is defined. It consists of 6 rows and 35 columns.
11
When the text area gets focus (that is, when the user clicks his or her mouse any-
where in the text area box), the handler
check()
is invoked. A reference to this
form is passed as an argument.
12
This is an image input type used instead of a submit button. When the user clicks
the image of the pizza man, the
OK()
handler will be invoked (see Figures 11.44
and 11.45).