Note that there are some explanatory texts on larger screens.

plurals
  1. POAJAX if Statement Help for generating Discounts
    text
    copied!<p>I have a problem that maybe someone could help me with.</p> <p>I'm creating a order form script for a client where the user can fill out an enquiry form that contains a simple calculator. So the user will be able to type in name, address, email etc.</p> <p>As well as this there are four text boxes saying to fill out a reference number of the product they are enquiring about. Then a text box for quantity, a text box for price, and a text box for the total.</p> <p>This is repeated 3 times and then there is a text box for a grand total. So by using JavaScript it automatically generates a grand total depending on what they fill out. This is the JavaScript code is created:</p> <pre>function calculate() { QtyA = 0; QtyB = 0; QtyC = 0; TotA = 0; TotB = 0; TotC = 0; PrcA = 0; PrcB = 0; PrcC = 0; //Below the code for the price if (document.ofrm.prcA.value > "") { PrcA = document.ofrm.prcA.value }; document.ofrm.prcA.value = eval(PrcA); if (document.ofrm.prcB.value > "") { PrcB = document.ofrm.prcB.value }; document.ofrm.prcB.value = eval(PrcB); if (document.ofrm.prcC.value > "") { PrcC = document.ofrm.prcC.value }; document.ofrm.prcC.value = eval(PrcC); //Below the code for the quanity if (document.ofrm.qtyA.value > "") { QtyA = document.ofrm.qtyA.value }; document.ofrm.qtyA.value = eval(QtyA); if (document.ofrm.qtyB.value > "") { QtyB = document.ofrm.qtyB.value }; document.ofrm.qtyB.value = eval(QtyB); if (document.ofrm.qtyC.value > "") { QtyC = document.ofrm.qtyC.value }; document.ofrm.qtyC.value = eval(QtyC); //Get the totals for the calculator (May need to be altered) TotA = QtyA * PrcA; document.ofrm.totalA.value = dm(eval(TotA)); TotB = QtyB * PrcB; document.ofrm.totalB.value = dm(eval(TotB)); TotC = QtyC * PrcC; document.ofrm.totalC.value = dm(eval(TotC)); Totamt = eval(TotA) + eval(TotB) + eval(TotC) ; document.ofrm.GrandTotal.value = dm(eval(Totamt)); }</pre> <p>What I'm trying to do now is. Having a small discount script using AJAX. so if the total is between</p> <p>£55-£129 the user will get 10% discount £130-£249 the user will get 15% discount £250+ the user will get 25% discount.</p> <p>I hope someone can help me with this thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload