Link to home
Start Free TrialLog in
Avatar of dartanion_jm
dartanion_jm

asked on

Populate a list box with a combobox?

Acroforms - Javascript - Adobe Acrobat Pro v8.12

Hello all...

How can I use Acrobat javascript to populate a list box with the values from a combobox (each time values are added to the combobox)?

EXAMPLE:
        Combobox1     Listbox1

        one                   one
        two                    two
        three                 three
           ----------------------
   -User Adds "four" to Combobox1
   
   -Script clears and repopulates
    Listbox1 with all values from
    Combobox1
 
        Combobox1     Listbox1

        one                   one
        two                    two
        three                 three
[Added] four              four

The insertItemAt method isn't really dynamic enough for my needs.

I placed the following Keyboard Script in Combobox2, to populate Textbox2 with the
selection from Combobox2:

var targ1=getField("Textbox2");
if(!event.willCommit){
    targ1.value=event.change;
}

Can it be modified to populate Listbox1 with the Combobox1 values?

Thanks in advance.
Avatar of Karl Heinz Kremer
Karl Heinz Kremer
Flag of United States of America image

Use something like this in the Validate event for your combo box:



var v = event.value;
var items = ["one", "two", "three"];
if (v != "one" && v != "two" && v != "three")
{
    items.push(v);
}
var l = this.getField("ListBox");
l.setItems(items);

Open in new window

SOLUTION
Avatar of Karl Heinz Kremer
Karl Heinz Kremer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dartanion_jm
dartanion_jm

ASKER

11/09/08  Sorry for the delay. Khkremer's solution worked. He is "The One".Award all 500 points.