I have created a form in Acrobat Pro 9 and had all types of different simple calculations on top. These calculations make a subtotal.
On this subtotal there is the option to attach taxes or not. Whenever you select taxes (19%) the calculation has to be subtotal*0.19 ofcourse, but whenever you select the 0% taxes then you have to get 0.
But the biggest problem is how do I sum up the selected taxes with the subtotal (which goes to Total). I heard and read about some "if" calculations, but it's not really understandable.
I'm quite new to Acrobat Pro 9.
Now let's also say you have a (hidden) text field called Tax which has the value 0.19. We'll use that one for the tax calculation instead of hard-coding the value into the script. That way you could easily adjust it in the future, if necessary. And then there's a checkbox called UseTax, which determines whether or not the tax should be calculated.
Now use the following code as the custom calculation script of SubTotalTax:
var useTax = (getField("UseTax").value != "Off");
if (useTax) {
event.value = getField("SubTotal").value * getField("Tax").value;
} else {
event.value = 0;
}
Your Total field can simply be the sum of SubTotal and SubTotalTax. The only thing you need to make sure is that the calculation order is correct, ie that Total is calculated last, SubTotalTax before it, and SubTotal before that.
- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com