2 Replies Latest reply on Aug 28, 2014 5:43 AM by lapneto

    Creating ComboBox with values of fields

    lapneto Level 1

      Hey everyone, it has been a while since my last post.

      I spent quite some time in google trying to populate a ComboBox with the values of 3 different form fields and was wondering if anyone could point me on the right direction.

      Many thanks for any insight!

        • 1. Re: Creating ComboBox with values of fields
          George_Johnson MVP & Adobe Community Professional

          the general idea would be something like this:

           

          // Get the field values added to an array

          var aItems = [];

          aItems.push(getField("Text1").valueAsString);

          aItems.push(getField("Text2").valueAsString);

          aItems.push(getField("Text3").valueAsString);

           

          // Populate the combo box with the items

          getField("combo1").setItems(aItems);

           

           

          Replace the field names with the actual field names you're using.

           

          You may want to start the list with an item that's a single space (so it appears blank) or something like "-- Select Item --". You will also want ensure that you don't add any duplicate entries, which would happen if any of the field values are the same.

           

          When did you want this script to execute?

          • 2. Re: Creating ComboBox with values of fields
            lapneto Level 1

            Hi George,

            Many thanks for your help, it is much appreciated! It worked like a charm.

            The script will run when the user clicks the combo, it works fine... however, I will have several combo boxes (ComboBox1, ComboBox2 etc) with the same options populated. Is there a way to code in such a way that referencing to eacho combo box? I will need to spawn pages, so I need to have a code to reference to that kind of dynamically.

            Thanks again!!!

            Best Regards,