...

View Full Version : Problem with double combo



Dalixam
03-21-2004, 04:59 PM
I used the example of a double combo script (http://wsabstract.com/script/cut183.shtml ) to make my own. I only changed a few things; mostly renamed the names of the form and the select boxes and removed the go function as I don't need that.

Anyway, my script looks like this and it works perfectly:



<script>
<!--

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

group[0][0]=new Option("<-- No subcategory selected-->","-1")

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

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

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

var temp=document.form.subcategory

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

//-->
</script>


However, when I change the options to my own options it doesn't work. That's all I've changed and I can't see what's wrong.



<script>
<!--

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

group[0][0]=new Option("<-- No subcategory selected-->","-1")

group[1][0]=new option("Star Wars","1")
group[1][1]=new option("Indiana Jones","2")

group[2][0]=new option("Sam & Max","3")
group[2][1]=new option("RollerCoaster Tycoon","4")

group[4][0]=new option("Pirates","5")

var temp=document.form.subcategory

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

//-->
</script>


Any idea as to why the latter doesn't work?

Mr J
03-21-2004, 11:29 PM
What is the number refering to?


("Star Wars","1 ")

Dalixam
03-21-2004, 11:46 PM
Does that matter? It's just the value for that selection in the drop down menu. Right now it refers to nothing, it's just an example.

glenngv
03-22-2004, 09:35 AM
Why did you skip group[3]?


...
group[2][1]=new option("RollerCoaster Tycoon","4")

group[4][0]=new option("Pirates","5")
...


Also, you need to change option to Option.

Dalixam
03-22-2004, 12:34 PM
The group 3 thing was not the problem, but it was that I had used o instead of O. I can't believe I missed that. Thanks for pointing it out :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum