
458
Part III
Adding Advanced Design Features
Forms and AP elements
When you’re mixing forms and AP elements, follow only one rule: Always put the form completely
inside the AP element. If you place the AP element within the form, all form elements after the AP
element tags are ignored. With the form completely enclosed in the AP element, the form can safely
be positioned anywhere on the page and all form elements still remain completely active.
Although this rule means that you can’t split one form onto separate AP elements, you can set up
multiple forms on multiple AP elements—and still have them all communicate to one final CGI or
other program. This technique uses JavaScript to send the user-input values in the separate forms to
hidden fields in the form with the Submit button. Suppose, for example, that you have three sepa-
rate forms gathering information in three separate AP elements on a Web page. Call them formA,
formB, and formC on apDiv1, apDiv2, and apDiv3, respectively. When the Submit button in formC
on layer3 is selected, a JavaScript function is first called by means of an
onClick event in the but-
ton’s
<input> tag. The function, in part, looks like the following:
function gatherData() {
document.formC.hidden1.value = document.formA.text1.value
document.formC.hidden2.value = document.formB.text2.value
}
Notice how every value from the various forms is sent to a hidden ...