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

Calculation Script for Checkboxes

New Here ,
Sep 19, 2017 Sep 19, 2017

I am looking to expand on another calculation script I am using for counting check boxes.

My PDF Document has a series of questions with which a "Yes" "No" or "N/A" option can be checked. The check boxes are named in the following format:

Yes.Q1, Yes.Q2, Yes.Q3...

No.Q1, No.Q2, No.Q3...

Na.Q1, Na.Q2, Na.Q3...

This is what I am using in order to count "Yes" answers on the checklist in a field below:

var nSum = 0;var aCkFlds = this.getField("Yes").getArray();for(var i=0;i<aCkFlds.length;i++){if(aCkFlds.isBoxChecked(0))nSum++;}event.value = nSum;

This works great for that. I want to expand the script for another field in which it will add the "Yes" and "No"  in order to get a count of all "Applicable Items" in the checklist.

Any assistance would be appreciated.

TOPICS
Acrobat SDK and JavaScript , Windows
479
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 19, 2017 Sep 19, 2017

This should do the trick:

var nSum = 0;

var yesFields = this.getField("Yes").getArray();

for (var i=0; i<yesFields.length; i++){

    if (yesFields.isBoxChecked(0)) nSum++;

}

var noFields = this.getField("No").getArray();

for (var i=0; i<noFields.length; i++){

    if (noFields.isBoxChecked(0)) nSum++;

}

event.value = nSum;

Translate
Community Expert ,
Sep 19, 2017 Sep 19, 2017
LATEST

This should do the trick:

var nSum = 0;

var yesFields = this.getField("Yes").getArray();

for (var i=0; i<yesFields.length; i++){

    if (yesFields.isBoxChecked(0)) nSum++;

}

var noFields = this.getField("No").getArray();

for (var i=0; i<noFields.length; i++){

    if (noFields.isBoxChecked(0)) nSum++;

}

event.value = nSum;

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