1 Reply Latest reply on Apr 11, 2011 10:56 AM by George_Johnson

    How to create a group/list of check box variables for display in text field, in appended format

    rhunter100

      I need to identify a series of single-response checkbox variables and display the ones selected (as a group) in a text field in an appended (comma, space) format. Last week, you provided a great little script for a similar need using List Box (multiple response) variables. This time I need to know how to formally identify the checkbox variables and, I presume, use a similar script to display the results in a comma, space format.

       

      You've been of great help.

       

      Thanks

        • 1. Re: How to create a group/list of check box variables for display in text field, in appended format
          George_Johnson MVP & Adobe Community Professional

          Here's the script adapted to this situation. It assumes there are ten check boxes named cb1, cb1, cb2, ...cb10.

           

          // Custom Calculate script for text field
          (function () {
          
              // Initialize the string
              var v, s = "";
          
              // Loop through the check boxes to build up a string
              for (var i = 1; i < 11; i++) {
          
                  // Get the value of the current check box
                  v = getField("cb" + i).value;
          
                  if (v !== "Off") {
                      if (s) s += ", ";  // Add a comma and a space if needed
                      s += v;  // Add the selected value
                  }
              }
          
              // Set this field value to the string
              event.value = s;
          
          })();
          

           

          You'll have to change the field name and starting/ending numbers to match your form.