10 Replies Latest reply on Jan 18, 2013 10:06 AM by stanford.utah

    Count checkboxes with 500+ unique names


      The form I am using a simple checklist, that was generated in Word and converted to a form in Acrobat, which is why it has so many unique field names.


      I found the following solution but I am looking for something more elegant and that doesn't require me to enter each unique name.


      I added the following script to the  document level function :

      function CountCheckBoxes(aFieldNames) {
      // count field names that have been selected
      var count = 0;
      var cField = "";
      // loop through array of field names
      for(i = 0; i < aFieldNames.length; i++) {
      // for field names with a value of not Off increment counter
      if(this.getField(aFieldNames[i]).value != "Off") count++;
      } // end loop of field names
      // return count
      return count;
      } // end CountCheckBoxes


      I also added text field with the following custom calculation script:

      // var define field names to be tested
      var aFields = new Array('uniquename', 'anothername...etc');
      // count field names that have been selected
      event.value = CountCheckBoxes(aFields);


      In order to quickly add 500+ field names, I use a temporary field to grab all the field value by using Pick under Calculate sum. I then cut and paste them into notepad and replace the



      ', '

      then a copy the full text into the above code replacing 'uniquename', 'anothername...etc'


      It works but it is lengthy and I hoping a code guru might have a smarter solution.