HTML and CSS Reference
In-Depth Information
EXPLANATION
1
A function called okForm() is defined. The function is called by the onSubmit event
handler. Its purpose is to ensure that a checkbox has been checked before allowing
the user to submit the form. If it has, the return value is true , and the form will be
submitted. If not, the user will be reminded to check the box, false will be returned,
and the form will not be submitted. See Figure 13.24. Once the checkbox has been
checked, and the submit button labeled “Go to Checkout” clicked, the form will be
submitted to the URL address assigned to the form's action attribute; in this case a
PHP script called “processform.php” (see Figure 13.25).
2
The action attribute is the URL of the server where the form data will be sent for
processing, once it has been submitted.
3
The onSubmit event handler is triggered when the user clicks the submit button
for this form.
4
This is the part of the form where the user enters data to be sent to the server-side
program for processing.
5
This is the checkbox that must be clicked before the user can submit the form.
The okForm() checks to see if this box was checked before allowing the form to
be submitted.
6
When this submit button, labeled “Go to Checkout” is pressed, the onSubmit han-
dler on line 3 is triggered.
7
When the user presses this button, the onClick handler will be fired up, and cause
the page to be redirected to the shopping cart page for the site.
Figure 13.24 The user cannot go to checkout (i.e., submit the form) until he or she
clicks the little box at the left.
Search WWH ::




Custom Search