mcgrathken.kmg
Posts: 0
Joined: Sat Feb 04, 2012 6:03 pm

Triple Dynamic Drop down list

I have a Dynamic list working for 2 lists just like your Dynamic list tutorial, however i cannot get it to work for 3 select lists.
Can you kindly show how to achieve this using java Script and possibly expand on the tutorial.Perhaps something as shown below.
Much appreciated Image

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Triple Dynamic Drop down list

What exactly is not working? Can you post the code that you tried?

mcgrathken.kmg
Posts: 0
Joined: Sat Feb 04, 2012 6:03 pm

Triple Dynamic Drop down list

I am trying to extend your dynamic list example to work for 3 drop down lists.
The name of lists are
1.typeList
2.dynamicList
3.colorList
here is the code i am trying to extent.

---------------------------------------------------------------------------------------------------------

var selectedValue = this.value;

var data = { 'fruits': ['orange', 'apple', 'banana'],
'vegetables': ['onion', 'carrot', 'tomato']
'color': ['green', 'yellow','orange','red', 'brown']
};

var dropDown3 = $('[name=colorList]');
dropDown3.html('');
var newData = data[selectedValue];

for(i = 0; i < newData.length; i++) {
dropDown3.append('​' + newData + '');
}
dropDown.selectmenu('refresh');

---------------------------------------------------------------------------------------------------------

so basically if fruits and banana was chosen from list 1 & 2 then the colorList should be filtered to show just "yellow".
I have it working for 2 but I can get it working for 3.
There is other ways using Switch case statements but i would like to use the JavaScript from your tutorial as i have used it on other screens and would like to keep my code consistent.
Thanks again Max

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Triple Dynamic Drop down list

You are missing a comma after "'tomato']". There are might be other problems, but this is the first thing that I noticed.

mcgrathken.kmg
Posts: 0
Joined: Sat Feb 04, 2012 6:03 pm

Triple Dynamic Drop down list

I have put the comma in but it still didn't make a difference.
i require list 3 to show only what depends on what's select in list1 and list2.
Take example
'vegetables': ['onion', 'carrot', 'tomato']

there is one argument which says if vegetables is chosen then only display
'onion', 'carrot', 'tomato'
so my question is how do I give it 2 arguments which should only display in list 3 depending on selection in list1 and list2.

thanks Max

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Triple Dynamic Drop down list

You will need to add if-statements to check what fruit or vegetable combination was selected. Use the Console window in Chrome Developer Tools to debug your app. You can always put console.log(value) to print values.

mcgrathken.kmg
Posts: 0
Joined: Sat Feb 04, 2012 6:03 pm

Triple Dynamic Drop down list

Ok Max thanks.
I'm not to well up on using java Script can you please get me started where to begin using the example above.
Thanks Max

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Triple Dynamic Drop down list

If you Google, you will find large number of resources on how to use if-statement.

Return to “Issues”