1 Reply Latest reply on Oct 29, 2008 10:37 PM by George_Johnson

    Adding up Column of Radio Buttons

      I am creating a survey within Acrobat to distribute.

      For each question, I have a row of 3 Radio Buttons. The first radio button for each question has a value of '1', the second '2' the third '3' etc.
      That repeats for 15 questions.

      My problem, I need to create a total at the bottom of each column to indicate how many times the user answered '1' to a question or '2' to a question etc.

      How would I pull that or what would the script be? Does anyone have any guidance? It would be very appreciated.

      Thanks.
        • 1. Re: Adding up Column of Radio Buttons
          George_Johnson MVP & Adobe Community Professional
          The following code is intended to be a document-level function that gets called from each of the radio button's Mouse Up event. It loops through the rows of radio buttons, gets the totals, and places the values in text boxes. You'd have to change the field names to match your form, but you should get the idea.


          function updateRadioCounts() {

              // Initialize object holding counts
              var counts = {val_1: 0, val_2: 0, val_3: 0, val_Off: 0};

              var i, val;

              // Loop through the 15 radio button fields
              for (i = 1; i < 16; i += 1) {

                  // Get value of current radio button
                  val = getField("radio" + i).value;

                  // Increment corresponding value
                  counts["val_" + val] += 1;
              }

              // Update text fields showing counts
              getField("Text1").value = counts["val_1"];
              getField("Text2").value = counts["val_2"];
              getField("Text3").value = counts["val_3"];
              getField("TextOff").value = counts["val_Off"];

          }


          George