Hi:

As you'll see in a minute, I'm no ace with JavaScript. However, I have this function that works perfectly whenever I test it, and it usually works in production, but sometimes it doesn't. It's for an order page, and the "specials" are

1) Buy 2, get 1 free
2) Buy 4, get 3 free
3) Buy 6, get 4 free

And so on. The script is designed so that the customer always gets the maximum possible number of free units.

Regular price is $25.00 per unit, sale price is $21.00 per unit for quantities of 6 or more.

Here's the code - I removed the other functions, plus names have been changed to protect the innocent :

<script language="JavaScript">
function CalcProduct() {
Price=25.00;
Discount=21.00;
Floor1=0
Floor2=0
Remainder1=0
Free=0;
Qty=document.form.QtyProduct.value;
if (Qty > 5) {
Price=Discount;
Floor1=Math.floor(Qty/4);
Remainder1=Qty-(Floor1*4);
Floor2=Math.floor(Remainder1/2);
Free=(Floor1*3)+(Floor2*1);
}
else if (Qty > 3) {
Free=3;
}
else if (Qty > 1) {
Free=1;
}
Total=Qty*Price;
Total=Math.round(Total*100)/100;
document.form.Product.value=Total;
document.form.QtyProduct.value=((Qty*1)+(Free*1));
CalcTotals();
}
</script>

If someone enters "6" in the QtyProduct field, the total price becomes $126 (6 times the discounted unit price of $21.00), and the 6 automatically becomes a 10 to reflect the 4 free units the customer receives with the special. This is reflected on-screen via the above JavaScript, plus the order is e-mailed to my client, and a confirmation is e-mailed to the customer. Again, usually this all works just fine.

This morning, my client forwarded two orders to me that were placed within an hour of each other over the weekend. One was perfect: It showed a quantity of 10 and a total price of $126. But the other one showed a quantity of 6 and a total price of $126. That is, the price was properly calculated, but the 4 free units weren't added on. Since PART of the JavaScript worked, it can't be that the user has JavaScript disabled or is using a browser that is not JavaScript-capable. Is it possible, though, that a portion of my script is not compatible with certain versions of JavaScript? Can anyone help? Thanks!