7 Replies Latest reply on Jan 5, 2015 12:57 PM by Elizabeth Mocz

Form Creation Question - Using Formula in Acrobat PDF

I've created a form in excel and imported into Acrobat Pro XI to create a pdf that is automatically calculates the subtotal, discount, shipping, installation, sales tax etc..    The problem I have is that the total does not calculate properly when the discount field or sales tax field is zero.  Can someone tell me how to write code that if the "Discount" value is \$0.00, then the value will equal the subtotal amount? I should be able to then apply the same formula to the sales tax field.  Here is the formula I entered for the subtotal and calculating the discount:

event.value = this.getField ("Subtotal").value*this.getField ("Discount").value.

• 1. Re: Form Creation Question - Using Formula in Acrobat PDF

Why are you multiplying the values? You need to subtract the discount from the sub-total, like this:

event.value = this.getField("Subtotal").value - this.getField("Discount").value;

• 2. Re: Form Creation Question - Using Formula in Acrobat PDF

There are many fields, Gilad, and yes this particular one needs to be the way I have it formulated in my initial question.  This value is then used in another field called "DIscount Total" which is the subtraction formula you so kindly pointed out above.

At this point I just need my original question answered in regards to if that value is zero.

Thanks!

• 3. Re: Form Creation Question - Using Formula in Acrobat PDF

What do you want to happen in that case, then?

• 4. Re: Form Creation Question - Using Formula in Acrobat PDF

Do you see any errors when you open the  JavaScript console?

Have you checked the field calculation order?

• 5. Re: Form Creation Question - Using Formula in Acrobat PDF

I need to multiple the Subtotal field and the discount field they will then equal the total discount field.  If the discount field is 0%, then I need the total discount field to equal the subtotal field.

• 6. Re: Form Creation Question - Using Formula in Acrobat PDF

Ah, so it's a percentage field, not a dollar amount (as your original question suggested). In that case, you can use something like this:

if (this.getField("Discount").value==0) event.value = this.getField("Subtotal").value;

else event.value = this.getField("Subtotal").value * this.getField("Discount").value;

• 7. Re: Form Creation Question - Using Formula in Acrobat PDF

Worked like a champ!  Thank you for your help!