Calculation resulting from checkbox selection in pdf

New Here ,
Nov 26, 2020

Copy link to clipboard

Copied

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!

TOPICS
Edit and convert PDFs, PDF forms

Views

54

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

1 Correct Answer

Most Valuable Participant , Nov 27, 2020
try67 Most Valuable Participant , Nov 27, 2020
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";

Likes

Translate

Translate
Jump to answer Jump to answer
Most Valuable Participant ,
Nov 27, 2020

Copy link to clipboard

Copied

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?

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Nov 27, 2020

Copy link to clipboard

Copied

Hi,

Yes using Acrobat.

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

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Nov 27, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Nov 27, 2020

Copy link to clipboard

Copied

It's just called - Yes

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Nov 27, 2020

Copy link to clipboard

Copied

OK, then you can use this code as the custom calculation script of the subtotal field:

 

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") total*=0.8;
event.value = total;

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Nov 27, 2020

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Nov 27, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
CdnSalmon AUTHOR LATEST
New Here ,
Nov 27, 2020

Copy link to clipboard

Copied

Thanks so much!!

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more