Jump to content
xisto Community
Sign in to follow this  
kvarnerexpress

Dynamic Drop Down Lists

Recommended Posts

I've got 3 drop down lists. The first one changes what appears in the
second two.
For some reason the code below is only deciding to show me the first two
items that appear in the two drop down lists in question. So, this leads me
to believe the problem shuld be quite simple to solve! but i've been stuck
on it for a couple of hours now!

If someone could help me out here I'd be extremely extremely greatful!!!!


<select name="free_item" onchange="relate(this.form)"><option selected value="0">--Please select--</option><option value="test1">test product1</option></select><script LANGUAGE="JavaScript"><!--// Dynamic product sizes + coloursvar supported = (window.Option) ? 1 : 0;if (supported) {var active;var opt = new Array();opt[0] = new Array();opt[0][0] = new Array();opt[0][1] = new Array();opt[0][0][0] = new makeOption(" - - ", " - - ");opt[0][1][0]= new makeOption(" - - ", " - - ");opt[0][0][1] = new makeOption(" - - ", " - - ");opt[0][1][1]= new makeOption(" - - ", " - - ");opt[1] = new Array();opt[1][0] = new Array();opt[1][1] = new Array();opt[1][0][0] = new makeOption("Size", "Size");opt[1][0][1] = new makeOption("Small", "Small");opt[1][0][2] = new makeOption("Medium", "Medium");opt[1][0][3] = new makeOption("Large", "Large");opt[1][0][4] = new makeOption("Ex-Large", "Ex-Large");opt[1][1][0] = new makeOption("Colour", "Colour");opt[1][1][1] = new makeOption("Black", "Black");opt[1][1][2] = new makeOption("White", "White");opt[1][1][3] = new makeOption("Blue", "Blue");}function makeOption(text, view_opt) {this.text = text;this.view_opt = view_opt;}function relate(form) {if (!supported) {load(form, "free_item");load(form, "free_colour");return;}var options = form.free_size.options;for (var i = 1; i < options.length; i++) {options[0][i] = null;}var curAr = opt[form.free_item.selectedIndex];for (var j =0; j < curAr.length; j++) {options[j] = new Option(curAr[0][j].text, curAr[0][j].view_opt);}options[0].selected = true;var options = form.free_colour.options;for (var i =1; i < options.length; i++) {options[i] = null;}var curAr = opt[form.free_item.selectedIndex];for (var j = 0; j < curAr.length; j++) {options[j] = new Option(curAr[1][j].text, curAr[1][j].view_opt);}options[0].selected = true;}function load(form, name) {var view_opt = form[name].options[form[name].selectedIndex].value;return false;}// --></SCRIPT> <b>Size : </b><font face="arial" size="2"><select name="free_size"></select> <b>Colour : </b><select name="free_colour"></select></form>

Right that's it. See what you can do!

Share this post


Link to post
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
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.