MrAdam Posted December 14, 2006 Share Posted December 14, 2006 i have 2 select menus with the id's "type" and "model". When I select something from "type", i want "model" to update with the models of that type. I've already created part of the script to clear the "model" menu, but I was wondering what the best way to store the new options and how to then implement that into a for loop or another loop/if/switch/foreach. There are 25 'types' which all have about 4 to 6 'models' in them, so it's quite a lot of options... - thanks Link to comment Share on other sites More sharing options...
Beta Posted December 14, 2006 Share Posted December 14, 2006 use Arrays :)have a list of arrays like this: var Menu = new Array();Menu[0] = ["1", "2", "3", "4", "5"];Menu[1] = ["1", "2", "3", "4", "5"];Menu[2] = ["1", "2", "3", "4", "5"];function MenuClick(menu) { var List = document.getElementById("model"); for(var a = 0; a < List.getElementsByTagName("option").length; a ++) { List.getElementsByTagName("option")[a].innerHTML = Menu[num][a]; }}<option onclick="MenuClick(0);">Type 1</option> Something like that should work...although you may want to tidy it up, and make it more...well...useful and bigger..loli think you can also put arrays inside arrays:Menu[0] = [["0 innerHTML", "0 other stuff"], ["1 innerHTML", "1 other stuff"]];then have Menu[menu][a][0] or Menu[menu][a][1] Link to comment Share on other sites More sharing options...
MrAdam Posted December 15, 2006 Author Share Posted December 15, 2006 so if i had a menu called "C Class" .. and in it was "model 1", "model 2", "model 3", "model 4"... how would i save that and how what i access that?-Thanks for the help! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now