Jump to content

the best way to do this


MrAdam
 Share

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...