0
我有一個問題,也許有人可以幫助我。AJAX if語句幫助產生折扣
我爲客戶創建訂單表單腳本,用戶可以填寫包含簡單計算器的查詢表單。因此,用戶將能夠輸入姓名,地址,電子郵件等。
除此之外,還有四個文本框用於填寫他們詢問的產品的參考編號。然後是數量的文本框,價格的文本框以及總數的文本框。
這是重複3次,然後有一個總計的文本框。所以通過使用JavaScript,它會根據他們填寫的內容自動生成總計。這是創建的JavaScript代碼:
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)); }
我現在想要做的是。有一個使用AJAX的小折扣腳本。所以如果總數在
之間£55-£129用戶將獲得10%的折扣 £130-£249用戶將獲得15%的折扣 £250 +用戶將獲得25%的折扣。
我希望有人能幫助我,謝謝。
是這個JavaScript自動生成? – 2011-02-03 10:56:55