I'm trying to make an order form and I'd like to make it fill in some of the fields automatically by a calculation. Basically, there are 3 fields, 2 of them are just dollar amounts, the 3rd is a discount. I can have it multiply all 3, but only by putting the opposite percentage as the discount can I get the correct result (like, if I wanted a 20% discount, I would need to put in 80%). Does anyone know of a custom script that can account for this so that it will display the correct discount percentage while also giving a correct end product?
Assuming you have the following named 3 fields:
"SubTotal" = the subtotal of the purchases, numeric with 2 decimal places
"DiscoutRate" = the discount % percent to apply, percent with 0 decimal places
"DiscountAmount" = the "DiscountRate" times the 'SubTotal", numeric with 2 decimal places.
For the "DiscountAmount" field, you can use the following "Custom calculation script:
// compute the discount amount based on the discount rate
event.value = this.getField("DiscoutRate").value * this.getField("SubTotal").value;
// suppress a zero result
if (event.value == 0) event.value = "";
George Kaiser