Skip to main content
Participant
Sep 22, 2022 1:45 AM UTC
Answered

Conditional Calculation if Box is Checked

I'm using Adobe Acrobat Pro 2017.

I want the form to calculate an amount (bonus) if a specific box is checked. If the box isn't checked, then no calculation is required.

So far I have: event.value = this.getField("Salary").value * 25 / 100.0 which calculates the bonus (field called BonusTotal) as soon as a salary is entered, however, I don't want to see a bonus if the checkbox (called Bonus) is unchecked. What am I missing? Thank you!

 

Nesa Nurani
Nesa NuraniCorrect answer
Community Expert
Sep 22, 2022 4:46 AM UTC

Before calculating check that checkbox is checked, something like this:

if(this.getField("Bonus").isBoxChecked(0))
event.value = this.getField("Salary").value * 25 / 100.0;
else
event.value = "";

3 replies

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
Sep 22, 2022 4:46 AM UTC

Before calculating check that checkbox is checked, something like this:

if(this.getField("Bonus").isBoxChecked(0))
event.value = this.getField("Salary").value * 25 / 100.0;
else
event.value = "";

Translate
Maude6911Author
Participant
Sep 22, 2022 2:05 PM UTC

THANK YOU! I've searched for hours!

Translate