Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Conditional Calculation if Box is Checked

New Here ,
Sep 21, 2022 Sep 21, 2022

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!

 

TOPICS
Acrobat SDK and JavaScript
609
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 21, 2022 Sep 21, 2022

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
Community Expert ,
Sep 21, 2022 Sep 21, 2022

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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 22, 2022 Sep 22, 2022

THANK YOU! I've searched for hours!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 28, 2024 Oct 28, 2024
LATEST

Awesome, I used this to calculate GST for GST registered suppliers and just changed it so it calculated 15% GST if box what ticked:

if(this.getField("CheckBox1").isBoxChecked(0))
event.value = this.getField("Total").value * 0.15;
else
event.value = "";

 

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