2 Replies Latest reply on May 9, 2013 10:58 PM by aknaylor44

    Adding the number of checkboxes checked



      I have absolutely no programming experience at all... I was hoping someone might help me.  If I have check boxes for Sunday-Saturday for an entire month, (name them S1, M1, T1, W1, R1, F1, Sa1, etc...), what would the custom calculation script look like that would total how many of those boxes were checked on a form?


      The function of the form is to calculate the number of visits a therapist made in a given week for all of the patients seen, (Sunday-Saturday for maybe up to 20 patients), so the actual script would include up to 140 boxes looking for how many were checked. 


      Certainly, this is possible... right?




        • 1. Re: Adding the number of checkboxes checked
          try67 MVP & Adobe Community Professional

          Sure. Let's say you have a text field that should display the total number of boxes displayed.

          Use this code as that field's custom calculation script:


          var checkboxes = ["S1", "M1", "T1", "W1", "R1", "F1", "Sa1"]; // Enter here all the names of your checkbox fields

          var total = 0;

          for (var i in checkboxes) {

               var f = this.getField(checkboxes[i]);

               if (f==null) app.alert("Invalid field name: " + checkboxes[i]);

               else if (f.value!="Off") total++;


          event.value = total;

          • 2. Re: Adding the number of checkboxes checked
            aknaylor44 Level 1

            THANK YOU!!!!


            That worked absolutely perfectly, although I know you had know doubts.  I super appreciate it.  If I have any more interesting questions, I'll let you know!!  Thank you again!