Back to Mal's forms page
<<< Clicking on this logo will return you to my Mal's Forms home page.

View the page source!


With these forms (one for each number, 4, 8 or 12), we give the buyer either 1, 2 or 3 free of their choice of flavor. There is a script in the head area that controls the hidden div from the dropdown list. Then we have a script to show the running total in each form.

If the buyer tries to order more than 4, 8 or 12, a popup tells them this and on closing the popup, the window is refreshed. If the buyer orders less than 4, 8 or 12, then the free number is not passed to Mal's.

Each script is unique for each form, the form calls the script by using, in the first form: onblur="calcQtyOneFree()" in the second form: onblur="calcQtyTwoFree()" and so on. The first line of the script is function calcQtyOneFree() { or function calcQtyTwoFree() { and so on.

In the form line we have a unique form name: name="form1" name="form2" etc, I've also added two scripts, the first one checks if the buyer has ordered too many: if(this.totalone.value>4){alert('Maximum of 4. Please check your selection.');javascript:location.reload(true);return false;};

The second script checks the buyer has ordered the correct number to get the free product: if (document.form1.totalone.value ==4) {document.form1.qty4.value = 1; } With these scripts, as you can see from the second and third forms, the only thing that needs altering is; the value>4 (this checks if more than 4 have been ordered), the maximum number for the popup, the value ==4 which checks they have ordered the correct number to get the free product and, document.form1.totalone needs changing to document.form2.totaltwo for the second form etc.