Dalixam
03-21-2004, 03: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?
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?