View Full Version : Double Combo not working in stage 2

06-10-2010, 05:42 PM
I have the double combo script working on another website for an auto parts dealer with only 1 make so the options are Choose Model and then Choose Years for that model, i.e., 1979-1987 for one model and 1988-1994 for option 2 of the same model, and similar options for the other models. The links go to the cart for that Model/Year and everything works fine.

This time I'm trying to set up the same script where this auto parts dealer has 21 Makes with a span of years for each make: 2011 to 1969, i.e., about 40 years for every Make. This parts dealer wants the years listed first and then the makes and from there I'll link to the cart for the model.

I have the code set up (with only 4 years set up for the first Make as a test, which is VW/Audi) just so I can get it working, however after picking the year it's not letting me pick a make. It appears to choose one randomly with no other options. I have posted the code below minus most of the makes and years to save space

I have three questions:

1. Is this the right script for this search pattern?
2. Is there a way to fix this so I don't have to list 40 years for every make?this would cause massive code bloat.
3. Is there an error in my code?

PS. I'm not a Javascript programmer but do understand some of what it is doing.

<form name="doublecombo">
<select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
<option value="">Choose Year</option>

<select name="stage2" size="1">
<option value="">Choose Make</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("VW/Audi 2011","http://www.....")
group[0][1]=new Option("VW/Audi 2010","http://www.....")
group[0][2]=new Option("VW/Audi 2009","http://www.....")
group[0][3]=new Option("VW/Audi 2008","http://www.....")
group[1][0]=new Option("Acura","http://www.....")
group[2][0]=new Option("BMW","http://www.....")
group[3][0]=new Option("Geo","http://www.....")
group[4][0]=new Option("Honda","http://www.....")
group[5][0]=new Option("Hyundai","http://www.....")

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(){