View Full Version : DoubleCombo - Having trouble getting 2 menu working

07-30-2002, 04:04 AM
Hi there,

I cut and pasted the double combo script from javascript kit and originally it worked fine but now it's stopped working at all. I added some variables to it all but I didn't change the script so I was hoping someone might be able to help me work this out. Here's what I did:

The original script was set up with the first menu having 3 options and the second one had an amount dependant on which one was selected in the first menu. I've changed mine to have 8 options in the first menu and the second menu SHOULD come out with anything from 15-20 options depending on which option was selected in the first menu. Well, for some reason now when I select an option in the first menu NOTHING happens in the second. NOTHING at all. It's as if it's just dead. I haven't modified any of the script concerning the redirect function but perhaps if there is someone out there who can actually explain what each part of the script is there for, it might help ME to figure out where I've gone wrong.

Here is the original script:

<form name="doublecombo">
<p><select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
<option>Technology Sites</option>
<option>News Sites</option>
<option>Search Engines</option>
<select name="stage2" size="1">
<option value="http://javascriptkit.com">JavaScript Kit</option>
<option value="http://www.news.com">News.com</option>
<option value="http://www.wired.com">Wired News</option>
<input type="button" name="test" value="Go!"


Double Combo Script Credit
By JavaScript Kit (www.javascriptkit.com)
Over 200+ free JavaScripts here!

var groups=document.doublecombo.example.options.length
var group=new Array(groups)
for (i=0; i<groups; i++)
group[i]=new Array()

group[0][0]=new Option("JavaScript Kit","http://javascriptkit.com")
group[0][1]=new Option("News.com","http://www.news.com")
group[0][2]=new Option("Wired News","http://www.wired.com")

group[1][0]=new Option("CNN","http://www.cnn.com")
group[1][1]=new Option("ABC News","http://www.abcnews.com")

group[2][0]=new Option("Hotbot","http://www.hotbot.com")
group[2][1]=new Option("Infoseek","http://www.infoseek.com")
group[2][2]=new Option("Excite","http://www.excite.com")
group[2][3]=new Option("Lycos","http://www.lycos.com")

var temp=document.doublecombo.stage2

function redirect(x){
for (m=temp.options.length-1;m>0;m--)
for (i=0;i<group[x].length;i++){
temp.options[i]=new Option(group[x][i].text,group[x][i].value)

function go(){


At the top of the code it has the onChange command which I figure is what tells the program to move to the script which determines which information to output in the second drop down menu. I have kept this part the same in my own version so I don't know why it doesn't work. If someone could explain the FUNCTION redirect part to me I would be most appreciative