Previous Chapter's Examples-|-Next Example-|-Return to Chapter Listing

Example 17.1:
Incorporating Information From a Form

Fill in the form, then click on the button:
First Name:
Last Name:
Address:
City:
State/Province/Region:
Zip/Postal Code:
Country:

This is the script we used. In the HEAD... <SCRIPT LANGUAGE="JAVASCRIPT"> <!-- function Use(form) { var sFname = form.elements[0].value var sLname = form.elements[1].value var sAddr = form.elements[2].value var sCity = form.elements[3].value var sState = form.elements[4].value var sZip = form.elements[5].value var sCou= form.elements[6].value if (confirm("Let's just check that we got the right information, shall we? Your name is " + sFname + " " + sLname + ". Your address is " + sAddr + ", " + sCity + ", " + sState + ", " + sZip + ", " + sCou + ". Is that all correct?")) { alert("We've open an alert box if you click on OK, but you could do anything you want, such as move to another page using location='url'.") } } //--> </SCRIPT> Then this form: <FORM> First Name: <input type="text" size="30"><BR> Last Name: <input type="text" size="30"><BR> Address: <input type="text" size="30"><BR> City: <input type="text" size="30"><BR> State/Province/Region: <input type="text" size="30"><BR> Zip/Postal Code: <input type="text" size="30"><BR> Country: <input type="text" size="30"><BR> <input type="button" value="Next Page" onclick="Use(this.form)"> </FORM> Also, at the bottom of the form we moved focus to the first text box with this: <SCRIPT LANGUAGE="JAVASCRIPT"> <!-- document.forms[0].elements[0].focus() //--> </SCRIPT>
Previous Chapter's Examples-|-Next Chapter's Examples-|-Return to Chapter Listing