1 Reply Latest reply on Jul 7, 2015 4:05 PM by gkaiseril

    How to populate a text box based on selections made from a dropdown box or a list box.

    Cuerv07

      I am trying to populate a text box with selections from a pull down box or list box. The user can make multiple selections from the pull down or list box and have those choices listed in a text box with no repeating selections. Can this be done?

      Screen Shot 2015-07-07 at 3.46.23 PM.png

        • 1. Re: How to populate a text box based on selections made from a dropdown box or a list box.
          gkaiseril MVP & Adobe Community Professional

          The Acrobat JavaScript API Reference shows how for the currentValueIndices property.

           

          So if one wants to populate the field a little modification is needed:

           

          // custom JavaScript calculation for the display field of the selection(s);
          event.value = "";
          var f = this.getField("List Box1");
          var a = f.currentValueIndices;
          if (typeof a == "number")     // A single selection
            event.value = f.getItemAt(a, false);
          else {     // Multiple selections
          var aValues = new Array();
          for (var i = 0; i < a.length; i ++) {
             aValues[i] = f.getItemAt(a[i], false);
            } // end for loop;
          event.value = aValues.join(", ");
          } // end not number;