Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Pre-Fill Forms From Last Use

By Will Bontrager
2005-04-18


The JavaScript Below the Form

Three lines of JavaScript need to be put below the form. It doesn't matter where below the form, so long as it's after the tag.

This Java causes the form fields to be pre-filled in, which is the reason the code needs to be below the form. If the code were above the form, the browser might try to execute the JavaScript before the form is loaded.

Here is an example of the three lines of JavaScript:

<script type="text/javascript" language="JavaScript"><!--

PopulateFormFields('formname','_____');
//--></script>
Replace formname with the name you gave the form.

Replace _____ with a list of this form's fields that you want the browser to pre-fill. The form field names are separated with a comma, like

fieldname1,fieldname2,fieldname3
Note: The information between the parenthesis should be exactly the same as the information between the parenthesis of the "onSubmit" attribute in the ACTION tag.

The demonstration page has examples.

Tutorial Pages:
» Pre-Fill Forms From Last Use
» Why?
» The Source Code
» The JavaScript code of the HEAD Area
» The Form's ACTION Tag
» The JavaScript Below the Form
» A Limitation
» Conclusion


Copyright 2004 Bontrager Connection, LLC


 | Bookmark
Related Tutorials:
» JavaScript Debugging Techniques with Firebug
» Striped Tables Using JavaScript
» Opening PDFs in a New Window with JavaScript
» Essential Javascript -- A Javascript Tutorial
» Submit Forms Conditionally using JavaScript
» How to Setup a Randomising Function