(originally published in the Possibilities ezine)
Not everybody is lucky enough to have Master Form V4 installed on their web sites. And some people are required to use proprietary form handling software for e-commerce or other site features or services from certain vendors.
This article will show how to emulate one of the cool features that come with the standard Master Form V4, a personalized "thank you" page.
The method described here is accomplished with JavaScript and cookies.
When your site visitor uses a form, the "thank you" page can be personalized. The personalization uses information the site visitor provided on the form.
When the form is submitted, JavaScript is used to store certain form information in a cookie.
Later, when the "thank you" page is loaded into the user's browser, JavaScript is used to retrieve the information from the cookie. Still using JavaScript, some or all of that information is inserted at pre-selected places on the web page.
The "thank you" page is personalized whenever it is loaded into the browser, whether immediately after the form is submitted or later on.
For example, the form might be submitted to an autoresponder or payment gateway. Later, the browser lands on the "thank you" page, which is then personalized.
In fact, other pages can use the same JavaScript as the "thank you" page does. If the site visitor provided a name on a form, for example, every page of the web site could be personalized with that name.
The web page with the form uses different JavaScript than the "thank you" page uses. Thus, two pages need JavaScript installed.
If you wish to personalize other pages in addition to (or instead of) the "thank you" page, follow the "thank you" page instructions for those pages.
To work with this system, form field names must begin with a letter and be composed only of letters, numbers, and underscore characters.
Put this JavaScript somewhere above the form. It may be in the HEAD area or the BODY area.
Verify the form has a name. A form name would be specified with the name="____" attribute in the FORM tag. Example: name="MyForm"
In the above JavaScript, at the place indicated, specify the form name.
Also in the above JavaScript, at the place indicated, specify the cookie name. This name will be used to store the cookie and must be identical to the cookie name in the JavaScript at the "Thank You" page, once that JavaScript is installed.
Now, do one of these two things (do only one, either one, but not both) with the web page form:
OR,
Only fields with a name can be cookied. Of fields with a name, these will not be cookied:
Here is an example form, for reference.
Put this JavaScript with the ReadCookieValues() function somewhere above the text to be personalized. It may be in the HEAD area or the BODY area.
In the above JavaScript, where indicated, specify the cookie name. This name must be identical to the cookie name in the JavaScript on the form web page.
Use the PrintPersonalizednfo() function to print a value wherever you want it printed.
PrintPersonalizednfo() requires at least one parameter and may have up to three parameters, in this order:
The field name must always be provided.
The default text is optional, but must be provided (null is okay) if any appending characters are provided.
Appending characters are optional.
Here are some examples —
Field name only:
PrintPersonalizednfo("email");
Field name and default text:
PrintPersonalizednfo("email","[provide email]");
Field name, default text, and appending character:
PrintPersonalizednfo("email","[provide email]",":");
Field name, null default text, and appending character:
PrintPersonalizednfo("email","",":");
Here is an example use of function PrintPersonalizednfo(). Notice that NOSCRIPT tags are in place, for this example, to accomodate browsers without JavaScript.
Here are a few more examples.
Will Bontrager
2006
Will Bontrager
Software Programmer
http://willmaster.com

|
|
|
Intuitive Web Site Design - What is it? Why should you care? Explore Concepts, Discover Advantages and Learn How-to’s of Intuitive Web Site Design
What Else is Inside?
Information, tips, tools and resources...