当学校(s1)选择“其他”时,所在校区(列表框s2),所在宿舍(列表框s3)隐藏起来,出现一个文本框(s4)用来填其他地址,请问这个功能如果实现呢?
<html>
<head>
<title>网页特效|Linkweb.cn/Js|---无刷新多级关联菜单</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><style>
body,select
{
 font-size:9pt;
 font-family:Verdana;
}
a
{
 color:red;
 text-decoration:none;
}
a:hover{
 text-decoration:underline;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
function Dsy()
{
 this.Items = {};
}
Dsy.prototype.add = function(id,iArray)
{
 this.Items[id] = iArray;
}
Dsy.prototype.Exists = function(id)
{
 if(typeof(this.Items[id]) == "undefined") return false;
 return true;
}function change(v){
 var str="0";
 for(i=0;i<v;i++){ str+=("_"+(document.getElementById(s[i]).selectedIndex-1));};
 var ss=document.getElementById(s[v]);
 with(ss){
  length = 0;
  options[0]=new Option(opt0[v],opt0[v]);
  if(v && document.getElementById(s[v-1]).selectedIndex>0 || !v)
  {
   if(dsy.Exists(str)){
    ar = dsy.Items[str];
    for(i=0;i<ar.length;i++)options[length]=new Option(ar[i],ar[i]);
    if(v)options[1].selected = true;
   }
  }
  if(++v<s.length){change(v);}
 }
}var dsy = new Dsy();dsy.add("0",["中山大学1","广州大学","其 他"]);dsy.add("0_0",["大学城校区"]);
dsy.add("0_0_0",["至1栋","至2栋"]);dsy.add("0_1",["大学城校区"]);
dsy.add("0_1_0",["B1栋","B2栋"]);
//-->
</SCRIPT>
<SCRIPT LANGUAGE = JavaScript>
<!--
//** Power by Fason(2004-3-11)
//** Email:[email protected] s=["s1","s2","s3"];
var opt0 = ["请选择学校","请选择校区","请选择宿舍"];
function setup()
{
 for(i=0;i<s.length-1;i++)
  document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")"); change(0);
  
}
//-->
</SCRIPT>
</head>
<body bgcolor="#E0E0E0" onLoad="setup()">
多级关联菜单:
<form name="frm" action="shiqu.asp">
<select name="s1" id="s1"><option>请选择学校</option></select>
<select name="s2" id="s2"><option>请选择校区</option></select>
<select name="s3" id="s3"><option>请选择宿舍</option></select>
</form>
</body>
</html>

解决方案 »

  1.   


    <html> 
    <head> 
    <title>网页特效|Linkweb.cn/Js|---无刷新多级关联菜单 </title> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <style> 
    body,select 

    font-size:9pt; 
    font-family:Verdana; 



    color:red; 
    text-decoration:none; 

    a:hover{ 
    text-decoration:underline; 

    </style> 
    <SCRIPT LANGUAGE="JavaScript"> 
    <!-- 
    function Dsy() 

    this.Items = {}; 

    Dsy.prototype.add = function(id,iArray) 

    this.Items[id] = iArray; 

    Dsy.prototype.Exists = function(id) 

    if(typeof(this.Items[id]) == "undefined") return false; 
    return true; 
    } function change(v){ 
    var str="0";
    if(document.getElementById("s1").value=="其 他") {
        document.getElementById("s2").style.display="none";
        document.getElementById("s3").style.display="none";
        document.getElementById("s4").style.display="";
    } else {
        document.getElementById("s2").style.display="";
        document.getElementById("s3").style.display="";
        document.getElementById("s4").style.display="none";
    }
    for(i=0;i <v;i++){ str+=("_"+(document.getElementById(s[i]).selectedIndex-1));}; 
    var ss=document.getElementById(s[v]); 
    with(ss){ 
      length = 0; 
      options[0]=new Option(opt0[v],opt0[v]); 
      if(v && document.getElementById(s[v-1]).selectedIndex>0 || !v) 
      { 
      if(dsy.Exists(str)){ 
        ar = dsy.Items[str]; 
        for(i=0;i <ar.length;i++)options[length]=new Option(ar[i],ar[i]); 
        if(v)options[1].selected = true; 
      } 
      } 
      if(++v <s.length){change(v);} 

    } var dsy = new Dsy(); dsy.add("0",["中山大学1","广州大学","其 他"]); dsy.add("0_0",["大学城校区"]); 
    dsy.add("0_0_0",["至1栋","至2栋"]); dsy.add("0_1",["大学城校区"]); 
    dsy.add("0_1_0",["B1栋","B2栋"]); 
    //--> 
    </SCRIPT> 
    <SCRIPT LANGUAGE = JavaScript> 
    <!-- 
    //** Power by Fason(2004-3-11) 
    //** Email:[email protected] var s=["s1","s2","s3"]; 
    var opt0 = ["请选择学校","请选择校区","请选择宿舍"]; 
    function setup() 

    for(i=0;i <s.length-1;i++) 
      document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")"); change(0); 
      

    //--> 
    </SCRIPT> 
    </head> 
    <body bgcolor="#E0E0E0" onLoad="setup()"> 
    多级关联菜单: 
    <form name="frm" action="shiqu.asp"> 
    <select name="s1" id="s1"> <option>请选择学校 </option> </select> 
    <select name="s2" id="s2"> <option>请选择校区 </option> </select> 
    <select name="s3" id="s3"> <option>请选择宿舍 </option> </select> 
    <input  name="s4" id="s4" style="display:none"> 
    </form> 
    </body> 
    </html>