Skip to main content
Participating Frequently
November 26, 2020
Answered

Calculation resulting from checkbox selection in pdf

Hi everyone,

I'm trying to write a calculation that will do the following:

If the checkbox is checked then it will deduct 20% from the subtotal. Can you please assist?

Thank you so much!

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
November 27, 2020

Thank you. I do also need to be able to show what the 20% off # in the field next to the checkbox line. Could you assist with this as well? Thank you.


Use this code as that field's calculation script:

 

var total = 0;
total+=Number(this.getField("TotalParts").valueAsString);
total+=Number(this.getField("TotalLabour").valueAsString);
total+=Number(this.getField("ShopSupplies").valueAsString);
if (this.getField("Yes").valueAsString!="Off") event.value = total*0.2;
else event.value = "0";

8 replies

try67
Community Expert
Community Expert
November 27, 2020

I'm assuming you have Acrobat, and not the free Reader, as it can't be done in the latter.

How are you currently calculating the subtotal? Do you use a script, or one of the other built-in calculation options?

Translate
CdnSalmonAuthor
Participating Frequently
November 27, 2020

Hi,

Yes using Acrobat.

The subtotal currently uses just the built-in calculation option - Sum of TotalParts, TotalLabour,ShopSupplies.

Translate
try67
Community Expert
Community Expert
November 27, 2020

OK, you will need to change it to a script. What's the name of the check-box field for the discount?

Translate