Expand my Community achievements bar.

Binding Drop Down Lists

Avatar

Level 2

Hello,

I am trying to figure out how i can bind drop down lists. I want it so if you choose a certain selection in drop down list 1, then you are only able to pick a certain selection out of drop down 2. So basically each selection in drop down 1 will give you different options to select in drop down 2. Sorry if i made that really confusing. Thanks

-Aaron-

6 Replies

Avatar

Level 10

Hi,

There are lots of examples for this, some dealing with states/provences. Check out John Brinkman's blog (Populating List Boxes). Also this thread touched on dropdowns as well (Re: Using submit by email - possible to auto email sender?); method 2 is what you are looking for.

Lastly if you are including bound values in your dropdown then this example shows how to access the display value and the bound value (Re: is it possible to get the key/value of the dropdown?).

Good luck,

Niall

Avatar

Level 2

ok i

im pretty new to this, i tried to follow Johns code but it got a little confusing becuase in my first drop down i have 9 different selections each which need to populate the second drop down with its own set of selections. So the second drop down has 87 possible choices that needs to go in it. So i guess i am just a little confused on where to start. attched is the excel file with all the data in it. the bold are what goes in the first category and the unbolds are the selections per category. I am not asking someone to do this for me but i would greatly appriciate it if someone could perhaps provide some code to where i can fill in all my data or just get me on the right track that would be sweet. Thanks

Avatar

Level 10

Hi,

Here is a mock-up version of the spreadsheet.

The first dropdown has the nine categories set in the Object / Field tab. Also have a look in the Object / Binding tab as there are values specified for each of the nine categories. These will be used later in the script.

The second dropdown does not have any values specified in the Object / Field tab.

Instead there is script in the exit event of the first dropdown. This is a switch statement that first of all looks at the bound value ("9030") of the choice that the user has made ("9030 National Marketing"). The statement then looks at each case until it gets to one that matches; then it runs the script for that case and then breaks from the switch statement.

Each case starts off with:

DropDownList2.clearItems();

DropDownList2.rawValue = null;

This is important because this clears the list in dropdown2 and sets its value to null. These two lines are then followed by a series of addItem() script which goes through all of the types in that category.

I have scripted all of 9030 and the first five lines of 9031. This should get you out of the traps. It is a bit of a pain, but just copy and paste downwards.

Each case ends with a "break;" and the last "}" closes the switch statement.

Good luck,

Niall

Avatar

Level 1

Hello

I am new to LC, although I have coded may different languages.

I am unable to understand why when I "remove" the code from script editor, that the preview and save/open PDF still work ok?

Seems that the script editor has NO effect since the XML still has code.

Which makes me think that you have to code in XML, not editor?

example- in script editor I changed the 9030 "Media-Ski" to "ZZZ- Ski"

When preview or save/open PDF, ZZZ did not show, the orginal "Media" is still there???

-Allan

Avatar

Level 10

Hi Allan,

No, I would always script and make changes in the script editor, always! I would not recommend making changes in the XML Source window, as you stand a risk of breaking the form.

Here is I make changes in the script editor, they are automatically reflected in the underlying XML source.

I suspect that it may be an issue with your version of LC Designer. What version are you using?

Niall