For line 2, the custom calculate script would be something like:
// Get the number ordered, as a number var num = +getField("A").value; // Calculate this field value and round to two digits to the right of the decimal event.value = util.printf("%.2f", num * 4.95);
Replace "A" with the actual name of the field.
For the shipping cost, it could be:
// Get the number ordered, as a number var num = +getField("A").value; // Set the default shipping price sp = 0; // Determine shipping price based on the number of items ordered if (num === 1) sp = 2.5; if (num >=2 && num <= 5) sp = 5 if (num >=6 && num <= 15) sp = 10 // Set this field's value to the shipping cost event.value = sp;
Note that this doesn't deal with numbers greater than 15, apart from setting it to 0.
There are a lot of good tutorials at acrobatusers.com, but you'll have to search around there a bit.
George, thank you so much. That was huge!
One more question: when I add the product and shipping costs together, I don't always get two digits after the decimal point. Can you tell me what to enter for the calculation script in order for cost+shipping to equal a number rounded to two decimals to the right of the decimal point? Would it be something like:
event.value = util.printf("%.2f", "Product_cost" + "Shipping")
It wold have to be something like:
event.value = util.printf("%.2f", +getField("Product_cost").value + +getField("Shipping").value);
But if you just want to change what gets displayed, you could set the Format of the field to Number and set the number of decimal places.