Expand my Community achievements bar.

Populating drop-down lists

Avatar

Level 2

I need some help with drop down lists.  I have 2 and require list #2 to populate according to the selection made in list #1.

DD List #1:

Dept 1

Dept 2

Dept 3

User chooses Dept 1, DD #2 will populate with:

Sub Dept toys

Sub Dept games

Sub Dept puzzles

User chooses Dept 2, DD #2 now populates with:

Sub Dept towels

Sub Dept sheets

Sub Dept napkins

User chooses Dept 3, DD #2 now populates with:

Sub Dept cookware

Sub Dept dishes

Sub Dept glassware

I know how to do binding in drop down lists, but that seems to only let you bind 1 to 1 (choose Dept 1 binds to Sub Dept toys).

Any guidance will be appreciated as our IT dept will not get to this for months and I'd hate to turn away an importatn client for something I  think I can do myself.

Cory

4 Replies

Avatar

Level 10

Hi Cory,

Basically the easiest way to do this is to have script in the preOpen event of DD#2, which looks back at the selected value in DD#1 and populates the dropdown with the appropriate choices.

There is an example here: http://assure.ly/jcTahK.

You should check out the scripts in each of the objects to get an understanding of what is going on.

Hope that helps,

Niall

Avatar

Level 10

Here is a sample to give you some ideas on how to do this..

Let me know if you have any issues..

https://acrobat.com/#d=CpmL3cuLdnNPeJ6Vc0IhdQ

Thanks

Srini

Avatar

Level 4

Hello Cory,

You can write the script in the "mouseEnter" event of  the DropDownList2 object.

if(DropDownList1.rawValue == "Dept1")

{

     DropDownList2.clearItems();

     DropDownList2.addItem("Sub Dept toys");

     DropDownList2.addItem("Sub Dept games");

     DropDownList2.addItem("Sub Dept puzzles");

}

if(DropDownList1.rawValue == "Dept2")

{

     DropDownList2.clearItems();

     DropDownList2.addItem("Sub Dept towels");

     DropDownList2.addItem("Sub Dept sheets");

     DropDownList2.addItem("Sub Dept napkins");

}

if(DropDownList1.rawValue == "Dept3")

{

     DropDownList2.clearItems();

     DropDownList2.addItem("Sub Dept cookware");

     DropDownList2.addItem("Sub Dept dishes");

     DropDownList2.addItem("Sub Dept glassware");

}

Thanks,

Debadas.

Avatar

Level 10

Hi Debadas,

I think that the mouseEnter event is too early to fire this script. The preOpen event works very well for populating the dropdown. In addition for this type of script I would recommend setting the value of DD#2 to null when DD#1 changes. This prevents the user going back and changing the selection of DD#1, while DD#2 is still showing a potentially incorrect selection.

Niall