Expand my Community achievements bar.

SOLVED

Select from a drop-down list and populate a list in a different drop-down

Avatar

Level 7

I have a drop-down list with 10 items in the list. If possible,  would like for a selection in this drop-down list to populate another drop-down list with a different list of selections. Each of the 10 items in the first list will each have a list of different options in the second drop-down list. I'm not sure how to construct this solution.

Thanks,

MDawn

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

That was due to the clear rawValue script that I put in the exit event of the businessFunction dropdown.

I have fixed it:

// clear the current selection in the department dropdown

dept0.rawValue = null;

dept0.execEvent("exit");

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

Good luck,

Niall

View solution in original post

10 Replies

Avatar

Level 10

Hi,

Here is an example where the dropdown's items are determined from three checkboxes.

https://acrobat.com/#d=cS2B8Nj17CFbw1D9-BAnQA

Notice that the preOpen event of the dropdown look back at the values of the checkboxes and the switch statement uses addItem(). It is the same principle with a dropdown populating a dropdown.

Hope that helps,

Niall

Avatar

Level 7

Hi, Niall,

I tried this and when I click in the second drop-down list nothing drops down and I'm getting a message in the debugger that says I'm missing a variable name.

Also, do I need the binding value and display fields for what I'm doing>

Margaret Dawn

630-850-1065

Avatar

Level 10

Hi Margaret,

No, you do not need the bound and display fields - they are just there for demo purposes and are not needed for the dropdown at all.

The script in the dropdown is fairly straightforward and in the example the script in the preOpen event does not use any variables:

// clear the dropdown displayed value and items

this.rawValue = null;

this.clearItems();


// repopulate the items based on the checkboxes

if(fruit.rawValue == 1)

{

     this.addItem("Apples", "fruit_001");

     this.addItem("Pears", "fruit_002");

     this.addItem("Oranges", "fruit_003");

     this.addItem("Bananas", "fruit_004");

     this.addItem("Grapes", "fruit_005");

}


if(cars.rawValue == 1)

{

     this.addItem("Volvo", "car_001");

     this.addItem("Ford", "car_002");

     this.addItem("Opel", "car_003");

     this.addItem("Toyota", "car_004");

     this.addItem("Nissan", "car_005");

}


if(counties.rawValue == 1)

{

     this.addItem("Co. Tipperary", "county_001");

     this.addItem("Co. Cork", "county_002");

     this.addItem("Co. Dublin", "county_003");

     this.addItem("Co. Clare", "county_004");

     this.addItem("Co. Kerry", "county_005");

}

Can you post your form?

Niall

Avatar

Level 7

I did use this script except I change the (fruit.rawValue == #) to be the first drop down list's name and then the appropriate number value for each choice in the drop down list.

Can you tell me how to post my form to the forum?

Thanks,

Margaret Dawn

630-850-1065

Avatar

Level 10

If you go to http://www.acrobat.com and upload the form there. You need to publish the form and then share the published link here in this thread.

Safari1.png

Niall

Avatar

Level 7

Thanks for the info.

I have published Business Impact Analysis at this link:

https://acrobat.com/#d=vizJeEqYo1bu5Caxb*dRBg

Margaret Dawn

630-850-1065

Avatar

Level 10

Hi Margaret,

Here is your form: https://acrobat.com/#d=MrWYQbTZIR7xJQDlm5ZSLg

The main problem is that you had named an object with a reserved word "function".

I changed  this and I am suggesting a clearItems line at the start of the preOpen script and a line in the businessFunction exit object to clear the rawValue of the department dropdown.

Hope this helps,

Niall

Avatar

Level 7

Thank you for your help.

Margaret Dawn

630-850-1065

Avatar

Level 7

That worked!

Now I'm having another very small problem. When I select a option in the first drop down list, the phrase "Please select from the list." Disappears. It doesn't work that way on the sample you sent. Not sure what I'm doing wrong.

Margaret Dawn

630-850-1065

Avatar

Correct answer by
Level 10

Hi,

That was due to the clear rawValue script that I put in the exit event of the businessFunction dropdown.

I have fixed it:

// clear the current selection in the department dropdown

dept0.rawValue = null;

dept0.execEvent("exit");

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

Good luck,

Niall