nikko50
02-21-2005, 01:09 PM
Hi all.
How can I initiate an onclick event with the 2nd select box? The code originally had a "GO" button but I would rather have an onclick event for the second box so I can do other things than just go to a url.
<!-- --><form name="doublecombo">
<p><select name="example" size="10" onChange="redirect(this.options.selectedIndex)">
<option>TEST</option>
<option>TEST2</option>
<option>TEST3</option>
</select>
<select name="stage2" size="10">
<option value=""> --- Reports --- </option>
</select>
</p>
<script>
<!--
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("test","javascript:onClick=alert('My Own JavaScript Alert Box!');")
group[1][0]=new Option("Art and Photo","javascript:onClick=http://simplythebest.net/affiliates/affiliate_programs/art_photo.html")
group[1][1]=new Option("Books","http://simplythebest.net/affiliates/affiliate_programs/books.html")
group[1][2]=new Option("Business","http://simplythebest.net/affiliates/affiliate_programs/business.html")
group[1][3]=new Option("Clothing","http://simplythebest.net/affiliates/affiliate_programs/clothing.html")
group[1][4]=new Option("Computers","http://simplythebest.net/affiliates/affiliate_programs/computers.html")
group[1][5]=new Option("Education","http://simplythebest.net/affiliates/affiliate_programs/education.html")
group[2][0]=new Option("Main index","http://simplythebest.net/scripts/DHTML_scripts/")
group[2][1]=new Option("Animation scripts","http://simplythebest.net/scripts/DHTML_scripts/dhtml_animation.html")
group[2][2]=new Option("Background scripts","http://simplythebest.net/scripts/DHTML_scripts/dhtml_background.html")
group[2][3]=new Option("Cookie scripts","http://simplythebest.net/scripts/DHTML_scripts/dhtml_cookies.html")
group[2][4]=new Option("Menu scripts","http://simplythebest.net/scripts/DHTML_scripts/dhtml_menu_scripts.html")
var temp=document.doublecombo.stage2
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>
</form><!-- -->
How can I initiate an onclick event with the 2nd select box? The code originally had a "GO" button but I would rather have an onclick event for the second box so I can do other things than just go to a url.
<!-- --><form name="doublecombo">
<p><select name="example" size="10" onChange="redirect(this.options.selectedIndex)">
<option>TEST</option>
<option>TEST2</option>
<option>TEST3</option>
</select>
<select name="stage2" size="10">
<option value=""> --- Reports --- </option>
</select>
</p>
<script>
<!--
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("test","javascript:onClick=alert('My Own JavaScript Alert Box!');")
group[1][0]=new Option("Art and Photo","javascript:onClick=http://simplythebest.net/affiliates/affiliate_programs/art_photo.html")
group[1][1]=new Option("Books","http://simplythebest.net/affiliates/affiliate_programs/books.html")
group[1][2]=new Option("Business","http://simplythebest.net/affiliates/affiliate_programs/business.html")
group[1][3]=new Option("Clothing","http://simplythebest.net/affiliates/affiliate_programs/clothing.html")
group[1][4]=new Option("Computers","http://simplythebest.net/affiliates/affiliate_programs/computers.html")
group[1][5]=new Option("Education","http://simplythebest.net/affiliates/affiliate_programs/education.html")
group[2][0]=new Option("Main index","http://simplythebest.net/scripts/DHTML_scripts/")
group[2][1]=new Option("Animation scripts","http://simplythebest.net/scripts/DHTML_scripts/dhtml_animation.html")
group[2][2]=new Option("Background scripts","http://simplythebest.net/scripts/DHTML_scripts/dhtml_background.html")
group[2][3]=new Option("Cookie scripts","http://simplythebest.net/scripts/DHTML_scripts/dhtml_cookies.html")
group[2][4]=new Option("Menu scripts","http://simplythebest.net/scripts/DHTML_scripts/dhtml_menu_scripts.html")
var temp=document.doublecombo.stage2
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>
</form><!-- -->