1 Reply Latest reply on Jan 11, 2013 7:14 AM by gkaiseril

    Counting number of Yes, No or NA Radio Buttons

    KBoulier74

      I have a PDF form with 20 radio button groups with Values of "Yes", "No" and "NA". I need a script to count the number of each value selected by the user.

        • 1. Re: Counting number of Yes, No or NA Radio Buttons
          gkaiseril MVP & Adobe Community Professional

          You need to create a custom JavaScript calculation and test each field's value and count the ones that meet your criteria.

           

          // create a variable to count "Yes" values

          var nYes = 0;

          // create a variable to count "No" values

          var nNo = 0;

          // create a variable to count "NA" values

          var nNA = 0;

          // create a variable to count "Off" values - unselected items

          var nOff = 0;

          // get the field value  for Check Box1

          var cValue = this.getField("Check Box1").value;

          // test the value and count as needed

          if(cValue == "Yes") nYes++; // increment counter

          if(cValue == "No") nNo++; // increment counter

          if(cValue == "NA") nNA++; // increment counter

          if(cValue == "Off") nOff++; // increment counter

          // get the field value  for Check Box2

          cValue = this.getField("Check Box2").value;

          // test the value and count as needed

          if(cValue == "Yes") nYes++; // increment counter

          if(cValue == "No") nNo++; // increment counter

          if(cValue == "NA") nNA++; // increment counter

          if(cValue == "Off") nOff++; // increment counter

          // report results

          var cMsg = "Yes answers: " + nYes + "\n";

          cMsg = cMsg + "No answers: " + nNo + "\n";

          cMsg = cMstg+ "NA answers: " + nNA + "\n";

          cMsg = cMstg+ Offo answers: " + nOff + "\n";

           

          You could simplify this by using a loop to process each field.