5 Replies Latest reply on Dec 21, 2016 8:53 PM by George_Johnson

    Multiple Combo-boxes Reference one List

    jmcrambo

      Hello All,

      I am in the process of developing a pdf form that will contain approximately 30 combo-boxes of employees names. I am looking to have all 30 combo-boxes reference one listing for their values as the list may be frequently updated and I do not want to have to update each of the 30 combo boxes every time a change needs to me made to the employee listing. I am looking for some input on how I can accomplish this easily. My thought was javascript or something may work. Thanks in advance for your help!

        • 1. Re: Multiple Combo-boxes Reference one List
          try67 MVP & Adobe Community Professional

          There are several ways you can do it.

          One is to place the data in a (hidden) text field and use a script to read it, analyze it and then use it for the drop-downs.

          Another, more complex option, is to use an attached text file to do the same.

          • 2. Re: Multiple Combo-boxes Reference one List
            jmcrambo Level 1

            Would you happen to have any guidance or sample code on how to do this? This will be my first attempt at something like this so the simplest option would probably be the best. Thanks!

            • 3. Re: Multiple Combo-boxes Reference one List
              try67 MVP & Adobe Community Professional

              This is not a very simple task for a beginner, but the basic code to do it using a text field would be something like this (let's say it's a multiline text field called "Items", with each line being a separate item, and the drop-downs are called "Selection1", "Selection2"... "Selection10"):

               

              var items = this.getField("Items").valueAsString.split("\r");
              for (var i=1; i<=10; i++) {
                   this.getField("Selection"+i).setItems(items);
              }
              
              • 4. Re: Multiple Combo-boxes Reference one List
                jmcrambo Level 1

                Thanks!

                 

                I created a multi-line text field called "items" and placed the employee names under the default value.

                 

                I then created a dropdown named "selection1" and added the script you provided above to this field.

                 

                When I attempted to check the script syntex, the following line is highlighted red "for (var i=1; i<=10; i++) {" with the radional provided of "error: synthax error near token '(' on line 2, column 5.

                 

                 

                form1.#subform[0].Selection1::initialize - (FormCalc, client)

                var items = this.getField("Items").valueAsString.split("\r"); 

                for (var i=1; i<=10; i++) { 

                     this.getField("Selection"+i).setItems(items); 

                 

                Are you able to provide me with any other guidance? Thank you again for your help.

                • 5. Re: Multiple Combo-boxes Reference one List
                  George_Johnson MVP & Adobe Community Professional

                  The script was intended for a form created in Acrobat, not LiveCycle Designer. Here's a link to the forum for that: LiveCycle Designer

                   

                  Also, you might want to ask where it would best to place the code.  If I were doing this, I would update the fields with the new items at design time, not every time the form was opened by a user, which would reset all of the dropdown field values, unless you added additional code to first store the current value and then set it back after the list was updated, assuming the previous value is included in the new list.