8 Replies Latest reply on Sep 22, 2015 2:46 PM by gkaiseril

    Can I set a field that summarizes a group of checkboxes?

    KBrown


      I have a few groups (Group1, Group2, etc.) of checkboxes where any number of boxes (Item1, Item2, Item3, etc.) may be checked.  I want to summarize all of the selections from each group into one summary field.  For example:  If Group1 had Items 1, 6, and 17 checked, I want the summary field for Group 1 to say "Item1; Item6; Item17".  Is this possible?  If so, would the code would need to be entered in each checkbox properties or in the summary field only or both?

       

      I'm using Adobe Acrobat XI Pro on Windows 7 Professional.

       

      Thanking you in advance for any help on this.

        • 1. Re: Can I set a field that summarizes a group of checkboxes?
          George_Johnson MVP & Adobe Community Professional

          Sure it's possible. Pick a group of check boxes and post again with the list all of the field names and their corresponding export values. Once you get the first group working, you can modify the script for use with the others.

          • 2. Re: Can I set a field that summarizes a group of checkboxes?
            gkaiseril MVP & Adobe Community Professional

            It can be done but you will need to do some custom JavaScript coding to access the fields and check the value of the fields. For a single check box there are at least 2 ways to see if has been selected. You can test the value, the unselected value is "Off" or if the isBoxChecked method.

            • 3. Re: Can I set a field that summarizes a group of checkboxes?
              KBrown Level 1

              There are too many checkboxes to do the whole list, but one group is "Email groups" with a few of the checkboxes' export values being "TAX", "Business All", "Collections All", "Field Audit Staff North", "Lawyers".  The summary box for this group will be "Email groups summary".  Would the whole group of checkboxes need to have the same name?  Once I have the basic code and a pattern to follow, I should be able to carry it through for all of my checkboxes.

              • 4. Re: Can I set a field that summarizes a group of checkboxes?
                KBrown Level 1

                GKaiseril - I have notes on how to populate when one box is checked, but I'm looking to summarize all of the boxes checked and enter the summary into one field.

                • 5. Re: Can I set a field that summarizes a group of checkboxes?
                  gkaiseril MVP & Adobe Community Professional

                  A lot of how you have created and coded the check boxes will determine how the code must work.

                   

                  I can create check boxes with very specific field names or use a generic name an number the fields. I could make a check box named "Gropup1" and then use the "Create multiple copies" and create a series of check boxes named "Group1.0", "Group1.1", "Group1.2", etc. I then set the export value for each field. This type of field name is known as Hierarchical naming. I can now use the getField method to get the top name, "Group1", to get that group object. Using the "getArray()" method I can create an array of the field objects that in the "Group1", Using that array I can program a loop to test every field in the group and push each none "Off" value into an array. Using the "join()" method I can create a list of the values from the checked fields. It is even possible to create a function to use the top level name and return the list of the values for the checked fields in that group of fields. I then only need to call the function with  parameter of the top name and I can populate the summary field for that group.

                   

                  An example:

                   

                  I create a document level function with a name of "GroupResult" and the following code:

                   

                  function GroupResult(cName) {

                  var oGroup = this.getField(cName);

                  var aGroup = oGroup.getArray();

                  var aResult = new Array();

                  for(var i = 0; i < aGroup.length; i++) {

                  if(aGroup[i].value != "Off") aResult.push(aGroup[i].value);

                  } // end for loop for array of fields;

                  // return list of selected items;

                  return aResult.join(", ");

                  }

                   

                  I have a group of check boxes name "Group1.0",  "Group1.1",  "Group1.2", and  "Group1.3" all with unique values when checked and I have a text field named "ResultsGrop1",

                   

                  The custom calculation script for the text field would be:

                   

                  event.value = GroupResult("Group1");

                   

                  If I had another group of check boxes labeled "Group2.#" the custom JavaScript for the text field would be:

                   

                  event.value = GroupResult("Group2");

                   

                  It makes no difference how many check boxes each group the script will adjust for the number of check boxes in the group.

                  • 6. Re: Can I set a field that summarizes a group of checkboxes?
                    KBrown Level 1

                    Oh, that works perfectly, GKaiseril!!! (Well, once I put the codes in the proper places, lol.)  Thank you so much!!

                    • 7. Re: Can I set a field that summarizes a group of checkboxes?
                      pixeljockey168

                      Is it possible to do this exact function but using a ListBox field to generate the multiple selections?

                      • 8. Re: Can I set a field that summarizes a group of checkboxes?
                        gkaiseril MVP & Adobe Community Professional

                        Yes, but one needs to account for the default value (since there usually is no null value or "Off" value), and whether one or many items have been selected.