位置:海鸟网 > IT > JavaScript >

三级下拉联动链接菜单

完整的代码如下:

<html>
<head>
<title>三级下拉联动链接菜单</title>
<meta http-equiv=content-Type content="text/html;charset=gb2312">
</head>
<body>
<div align="center">
<form name="isc">
<table border="0" cellspacing="0" cellpadding="0">
<tr align="center">
<td nowrap height="11">
<select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
<option selected>◤建站资源网◢</option>
<option>★CGI程序设计</option>
<option>★FLASH欣赏</option>
</select>
<select name="stage2" size="1" onChange="redirect1(this.options.selectedIndex)">         
<option value=" " selected></option>')         
<option value=" " selected>◤------第二层菜单------◢</option>  
<option value=" " selected>◤------第二层菜单------◢</option>  
</select>   
<select name="stage3" size="1" onChange="redirect2(this.options.selectedIndex)">        
<option value=" " selected></option>')         
<option value=" " selected>◤------第三层菜单------◢</option>   
<option value=" " selected>◤------第三层菜单------◢</option>   
</select></table> 
</form></div>   
<script language="JavaScript">
<!--
var groups=document.isc.example.options.length      
var group=new Array(groups)      
for (i=0; i<groups; i++)      
group[i]=new Array()      
      
group[0][0]=new Option("----第二层菜单----"," ");      
      
group[1][0]=new Option("」第一类"," ");      
group[1][1]=new Option("」第二类","47");      
group[1][2]=new Option("」第三类","46");      
group[1][3]=new Option("」第四类","45");      
      
group[2][0]=new Option("」第一类"," ");      
group[2][1]=new Option("」第二类","115");      
group[2][2]=new Option("」第三类","116");       
      
var temp=document.isc.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      
redirect1(0)      
}     

var secondGroups=document.isc.stage2.options.length      
var secondGroup=new Array(groups)      
for (i=0; i<groups; i++)  {      
secondGroup[i]=new Array(group[i].length)      
for (j=0; j<group[i].length; j++)  {      
secondGroup[i][j]=new Array()  }}      
      
secondGroup[0][0][0]=new Option("----第三层菜单----"," ");      
secondGroup[1][0][0]=new Option("----第三层菜单----"," ");      
secondGroup[1][1][0]=new Option("」 第一节"," ");      
secondGroup[1][1][1]=new Option("」 第一节","../cgi/pagenew8.htm");      
secondGroup[1][1][2]=new Option("」 第一节","../cgi/pagenew8.htm");      
secondGroup[1][1][3]=new Option("」 第一节","../explain/route.htm");      
      
secondGroup[1][2][0]=new Option("」第三类"," ");      
secondGroup[1][2][1]=new Option("第二节","../cgi/pagenew7.htm");      
secondGroup[1][2][2]=new Option("第二节","../cgi/pagenew7.htm");      
secondGroup[1][2][3]=new Option("第二节","../explain/route.htm");      
      
secondGroup[1][3][0]=new Option("」第四类"," ");      
secondGroup[1][3][1]=new Option("第三节","../cgi/pagenew15.htm");      
secondGroup[1][3][2]=new Option("第三节","../explain/route.htm");      
      
secondGroup[2][0][0]=new Option("----第三层菜单----"," ");      
secondGroup[2][1][0]=new Option("」第三类"," ");      
secondGroup[2][1][1]=new Option("」第三节(1)","../pictures/cartoon/1.htm");      
secondGroup[2][1][2]=new Option("」第三节(2)","../pictures/cartoon/2.htm");      
secondGroup[2][1][3]=new Option("」第三节(3)","../pictures/cartoon/3.htm");      
      
secondGroup[2][2][0]=new Option("」第四类"," ");      
secondGroup[2][2][1]=new Option("第三节l(1)","../pictures/email/1.htm");      
secondGroup[2][2][2]=new Option("第三节(2)","../pictures/email/1.htm"); 

var temp1=document.isc.stage3      
function redirect1(y){      
for (m=temp1.options.length-1;m>0;m--)      
temp1.options[m]=null      
for (i=0;i<secondGroup[document.isc.example.options.selectedIndex][y].length;i++){      
temp1.options[i]=new Option(secondGroup[document.isc.example.options.selectedIndex][y][i].text,secondGroup[document.isc.example.options.selectedIndex][y][i].value)      
}      
temp1.options[0].selected=true   
}   
function redirect2(){   
window.open(temp1.value,"","toolbar=no,location=yes,directories=no,status=no,menubar=no,scrollbars=yes, resizable=yes,copyhistory=yes,width=700,height=450");   
}   
//-->
</script>
</body>
</html>