1 Reply Latest reply on Sep 19, 2017 2:20 PM by try67

    Calculation Script for Checkboxes

    polishgerbils Level 1

      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[i].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.

        • 1. Re: Calculation Script for Checkboxes
          try67 MVP & Adobe Community Professional

          This should do the trick:


          var nSum = 0;
          var yesFields = this.getField("Yes").getArray();
          for (var i=0; i<yesFields.length; i++){
              if (yesFields[i].isBoxChecked(0)) nSum++;
          var noFields = this.getField("No").getArray();
          for (var i=0; i<noFields.length; i++){
              if (noFields[i].isBoxChecked(0)) nSum++;
          event.value = nSum;
          1 person found this helpful