求一个三级联动,是通过数据库进行联动的。

解决方案 »

  1.   

    或者哪位js高手顺手也一个简单的demo最好
      

  2.   

    这种网上的demo很多了楼主搜一下
      

  3.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <script src="area.js" type="text/javascript"></script>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title> 信息发布</title>
    </head>
    <body onLoad="setup();">
    <div style="width:980px; height:100%; margin:0 auto;">
    <div class="chotitle">
    <form id="senttype" name="formsent" method="post" style="margin:0;padding-top:15px">
    <table width="100%" border="0" cellspacing="0" cellpadding="7">
      <tr>
        <td width="13%">起&nbsp;&nbsp;点:</td>
        <td width="44%">
    <SELECT id="star_province" NAME="star_province"><option>省份</option></SELECT> 
       <SELECT id="star_city" NAME="star_city"><option>地级市</option></SELECT> 
       <SELECT id="star_county" NAME="star_county"><option>市、县级市、县</option>
       </SELECT> 
                   </td>
          </tr>
    </table>
    </form>
    </div>
    </div>
    </body>
    </html>js文件如下:
    // JavaScript Document
    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,obj,init){
     var str="0";
     for(i=0;i<v;i++)
     { str+=("_"+(document.getElementById(obj[i]).selectedIndex-1));}; //属性可设置或返回下拉列表中被选选项的索引号,若有多个选择,则返回第一个
       var ss=document.getElementById(obj[v]);
       with(ss){
        length = 0;
        options[0]=new Option(init[v],init[v]);
        if(v  &&  document.getElementById(obj[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<star.length)
        {change(v,obj,init);}
     }
    }var dsy = new Dsy();
    dsy.add("0",["安徽","河南"]);dsy.add("0_0",["安庆","蚌埠","巢湖"]);
    dsy.add("0_0_0",["安庆市","怀宁县","潜山县","宿松县","太湖县","桐城市","望江县","岳西县","枞阳县"]);
    dsy.add("0_0_1",["蚌埠市","固镇县","怀远县","五河县"]);
    dsy.add("0_0_2",["巢湖市","含山县","和县","庐江县","无为县"]);dsy.add("0_1",["郑州","南阳","安阳"]);
    dsy.add("0_1_0",["郑郑","郑州县"]);
    dsy.add("0_1_1",["宛城区","卧龙区","西峡","南召"]);
    dsy.add("0_1_2",["安阳县","安阳区"]);var star=["star_province","star_city","star_county"];
    var optstar = ["省份","地级市","市、县级市、县"];
    function setup() 
      {
      for(i=0;i<star.length-1;i++){
       document.getElementById(star[i]).onchange=new Function("change("+(i+1)+",star,optstar)");
      }
      change(0,star,optstar);
      }