Update a List Box Based on a Combo Box SelectionHello all,
So I have a few lists, in this case fruit and vegetables, and based on my selection on the combo box I would like to populate the list box with the new list. For example, if I have "fruit" selected, I want the list box to display oranges, apples, and grapes. The script I have works, but it doesnt evaluate the list AND I also do not want it to keep appending the list box with my selection. Is there a way around this?
TestArray = {"Fruit", "Vegetables"}; //my list of 'stuff'
Fruit = {"Oranges", "Apples", "Grapes"};
Vegetables = {"Corn", "Squash", "Eggplants"};
nw = New Window( "Sample",
<<MODAL></MODAL>Thanks!
Re: Update a List Box Based on a Combo Box Selection1. What has been returned is a List. To get the specific value from a list, all you have to do is to ask for the specific element from the list. In your case, there is only one element being returned, so you just have to specify
(tb2 << Get Selection)[1]
2. Your venture into JSL will remain a mistery until you spend the time reading the Scripting Guide. It describes not just the syntax, but even more impotantly, the language structures( Lists, Matrices, etc. ).
Help==>Books==>Scripting Guide
Re: Update a List Box Based on a Combo Box SelectionThanks Nelson! One last question, when I do tb2 << Get Selection, I get an output in {"Apples"} format, any way to convert to just "Apples"? Substr and Word function are not working.
Re: Update a List Box Based on a Combo Box SelectionThe main issue is that what is returned from the
cb << Get Selected
is not a variable name, as you were wanting it to be, but rather a string, "Fruit" or "Vegetables". That is, the names of the 2 list are Fruit and Vegetables, not "Fruit" and "Vegetables".
Below is a script that works the way you want. There are other ways to do this, that others may want to contribute
Names Default To Here( 1 );
TestArray = {"Fruit", "Vegetables"}; //my list of 'stuff'
Fruit = {"Oranges", "Apples", "Grapes"};
Vegetables = {"Corn", "Squash", "Eggplants"};
nw = New Window( "Sample",
<<MODAL></MODAL>
Re: Update a List Box Based on a Combo Box Selection@Ksrzg01,
Try this. The list needs to be evaluated before its elements can be populated into the list box and a way to acheive it is as shown below.
TestArray = {"Fruit", "Vegetables"}; //my list of 'stuff'
Fruit = {"Oranges", "Apples", "Grapes"};
Vegetables = {"Corn", "Squash", "Eggplants"};
MyLists = {Fruit,Vegetables};
nw = New Window( "Sample",
<<MODAL></MODAL>