Skip to main content
Participating Frequently
November 26, 2020
Answered

Calculation resulting from checkbox selection in pdf

  • November 26, 2020
  • 1 reply
  • 1321 views

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 has been closed for replies.
Correct answer try67

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";

1 reply

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?

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.

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?