Skip to main content
Participating Frequently
Nov 26, 2020 10:48 PM UTC
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
Nov 27, 2020 5:30 PM UTC

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
Nov 27, 2020 11:19 AM UTC

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
Nov 27, 2020 3:24 PM UTC

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
Nov 27, 2020 4:38 PM UTC

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

Translate