2 Replies Latest reply on Feb 25, 2017 7:59 AM by bobb39228641

    Summing a grid of radio buttons by column

    bobb39228641

      I'm trying to figure out how to sum a column of radio buttons. I've been presented with a form with 5 categories or questions that need to be rated from 1 to 5.  The layout is something like:

       

      Q1:  1     2    3    4    5

      Q2:  1     2    3    4    5

      Q3:  1     2    3    4    5

      Q4:  1     2    3    4    5

      Q5:  1     2    3    4    5

             T1  T2  T3  T4  T5

                Grand Total

       

      The idea being that as someone rates each question, the value of the checkbox they select is then summed at the bottom of the column so I wind up with a total of the 1s that were checked, 2s, etc.  I can do singleton radios or checkboxes but am a bit lost with multiples like this and would appreciate some assistance

       

      Many thanks in advance.

        • 1. Re: Summing a grid of radio buttons by column
          try67 MVP & Adobe Community Professional

          Whatever you use, put the value of each field as its export value (for check-boxes) or "radio button choice" value (for radio-button).

          You can then use something like this as the custom calculation code of the T1 field, for example:

           

          var total = 0;
          for (var i=1; i<=5; i++) {
              if (this.getField("Q"+i).valueAsString=="1") total++;
          }
          event.value = total;
          
          • 2. Re: Summing a grid of radio buttons by column
            bobb39228641 Level 1

            This was perfect.  I realized I got confused by the terminology Adobe was using for the value and took 'Radio Button Choice' to mean the field name and not the actual value.  Anyway, that works perfectly and I'll have a very happy co-worker on Monday as a result.

             

            Thank you so much.