View Full Version : Double Combo

02-20-2003, 01:20 PM
I have a problem with a scritp. You must know that this script is call Double Combo. What's the problem?, when i select in the first combo box an option and then select in the second combo box an obtion then i hit GO and then if i go BACK in the firs combo box is my option but in the second combo is not the obtions for it.
I have try to be more precise but this problem is wierd. This script is from this site.

02-20-2003, 01:43 PM
put the function you used to set the options for the second combo box in the onLoad for your <body> tag

02-21-2003, 08:22 AM
I have try this but, not working. I have use the function redirect(x) (see the script). What function i must use? If i use in stead of x, this.options.selectedIndex is an error because is not an object.
Please help me if you can.
Thanks!!! This is the script:

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

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")

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


02-21-2003, 08:33 AM
Hei !!! I have find it. How stupid i am. The function for onLoad is
redirect(doublecombo.example.options.selectedIndex) this is an object. Thanks a lot man!!!