3 Replies Latest reply on Apr 1, 2017 4:02 AM by migs012

    Muliti Check box Exported Data in a Text Field and Calculation

    migs012

      Hi Good day Everyone,

       

      I would like to seek support to answer my acrobat problem. Im doing a project specifically a multiple check box that has a specific value.

      Example: Check box 1, 2, 3, 4 & 5 have their values 1A, 1B, 1C, 1D 1E.  I wanted to get the result in the check box like this: 1A, 1B, 1C, 1D 1E.

      Would it be possible? I'm working with this code I got from one of the questions here:

       

      event.value = this.getField("1B").value;

      // if value is "Off" then clear the field

      if (event.value == "Off") event.value = "";

       

      It's working, only when you select one check box. What I wanted to do is to select multiple boxes and the result will be in a displayed in a comma.

       

      On the side, I want also to calculate the number of check box selected on text field that will support the result on the other text field.

       

      Example:

       

      Text Field (No of Check box Selected) 6

      Text Field (selected Check Boxes) 1A, 1B, 1C, 122B, 121B, 120B

       

      Thank you in advance for your support!

       

      Screen Shot 2017-03-31 at 1.08.49 PM.pngScreen Shot 2017-03-31 at 1.09.14 PM.png

        • 1. Re: Muliti Check box Exported Data in a Text Field and Calculation
          try67 MVP & Adobe Community Professional

          You can use this code as the custom calculation script of the field that should contain the list of selected items:

           

          var fields = ["1A", "1B", "1C", "1D", "1E"]; // Enter the full list of check-boxes here
          var values = [];
          for (var i in fields) {
              var f = this.getField(fields[i]);
              if (f==null) {
                  app.alert("Can't find: " + fields[i]);
                  continue;
              }
              var v = f.value;
              if (v!="Off") values.push(v);
          }
          event.value = values.join(", ");
          this.getField("Counter").value = values.length;
          

           

          The last line of the code will populate another field (called "Counter") with the number of selected boxes.

          • 2. Re: Muliti Check box Exported Data in a Text Field and Calculation
            migs012 Level 1

            Hi try67!

             

            Thank you so much! It works!

            How ever, for the counter code:

             

            this.getField("Counter").value = values.length;

             

            can I copy this an place in a different text box to display the number of check box selected?

            or do I need to copy and paste all of the code in a another text field to display the count?

             

            Lastly, will the result be limited to a certain number of check box only?

             

            Thank you again for your help!

            • 3. Re: Muliti Check box Exported Data in a Text Field and Calculation
              migs012 Level 1

              Hi @try67!

               

              Finally I got what you mean. I replaced the "Counter" with the text field name and it worked!

               

              Thank you and  More Blessings!