这是我以前写的三级互动,你看看有没有用???
<%set rs1=server.createobject("adodb.recordset")
sql1="select * from class1"
rs1.open sql1,conn,1,1
if rs1.eof then
topstr="没有分类"
else 
%> 
<script language = "JavaScript">
<!--
 <%
topstr="<option>选择一级分类</option>"
do while not rs1.eof
topstr=topstr&"<option value='"&rs1("class1id")&"'>"&rs1("class1name")&"</option>"
%>
<%set rs2=server.createobject("adodb.recordset")
sql2="select * from class2 where class1id="&rs1("class1id")
rs2.open sql2,conn,1,1
if not rs2.eof then%>
str<%=rs1("class1id")%>='<select name=class2id onChange="change3(document.myform.class2id.options[document.myform.class2id.selectedIndex].value);"><option>选择二级分类</option>';
 <%
 do while not rs2.eof 
%>
str<%=rs1("class1id")%>=str<%=rs1("class1id")%>+'<option value="<%=rs2("class2id")%>"><%=rs2("class2name")%></option>';
<%set rs3=server.createobject("adodb.recordset")
sql3="select * from class3 where class2id="&rs2("class2id")
rs3.open sql3,conn,1,1
if not rs3.eof then
%>
sstr<%=rs2("class2id")%>='<select name=class3id>';
 <%
 do while not rs3.eof
%>
sstr<%=rs2("class2id")%>=sstr<%=rs2("class2id")%>+'<option value="<%=rs3("class3id")%>"><%=rs3("class3name")%></option>';
<%
        rs3.movenext
        loop
        rs3.close%>
sstr<%=rs2("class2id")%>=sstr<%=rs2("class2id")%>+'</select>';
<%else%>
sstr<%=rs2("class2id")%>='没有分类';
<%end if %>
<%
        rs2.movenext
        loop
        rs2.close%>
str<%=rs1("class1id")%>=str<%=rs1("class1id")%>+'</select>';
<%else%>
str<%=rs1("class1id")%>='没有分类';
<%end if %>
<%
        rs1.movenext
        loop
        rs1.close
        %>
function change2(locationid){
if(!locationid)
window.file.innerHTML="";
else
window.file.innerHTML=eval("str"+locationid);
window.file2.innerHTML="";
return false;}
function change3(locationid){
if(!locationid)
window.file2.innerHTML="";
else
window.file2.innerHTML=eval("sstr"+locationid);
return false;}
//-->
</script>
<%end if%>
<table><tr><td><select onChange="change2(document.myform.class1id.options[document.myform.class1id.selectedIndex].value);" name="class1id" id="class1id">
<%=topstr%>
        </select></td><td><div id=file></div></td><td><div id=file2></div></td></tr></table>

解决方案 »

  1.   

    不知你所说的特殊是哪里?
    http://expert.csdn.net/Expert/topic/1965/1965486.xml?temp=.9115717
      

  2.   

    <!--月影飞鸿2003-05-25 晚-->
    <!--#include file = dbconn.asp-->
    <body onload =" ChangeProvince(document.all.Province);aa.window.close();">
    <%
      Dim Arr_City
      
      sub CloseRs(rs)
        Rs.close
        set Rs = nothing
      end sub
      
      Sql_All = "Select Id,Name from prover"
      set Rs_All = Server.CreateObject ("adodb.recordset")
      Rs_All.Open Sql_All,conn,3,1  
      
      '动态生成一个内容为省的select
      Response.Write "<center>"
      Response.Write "<Select name = Province id = Province onchange = ChangeProvince(this)>" 
      do while not Rs_All.EOF 
    %>
       <option value = <%=Rs_All("Id")%>><%=Rs_All("Name")%>
    <%
        Rs_All.MoveNext
      loop
      Response.Write "</Select>"
      '到此第一个select为止
      
      CloseRs(Rs_All)
      
      '在城市表city中选择所有记录。Id:城市Id;CId:省Id;Name:城市的名字。
      '然后按照:省Id加上“,”加上城市Id加上“,”加上城市的名字组合成一个字符串;
      '如:'1,2,济南',表示:省的Id是1,城市的Id是2,城市的名字是 济南。
      '然后每一个类似的字符串作为一个一维数组的一个元素的值。
      '如此循环,动态生成了一个数组,每一个下表的值为类似“1,2,济南”的字符串
      Sql_City= "select Id,CId,Name from city  order by Id"  
      set Rs_City = server.CreateObject ("adodb.recordset")
      Rs_City.Open Sql_City,conn,3,1
      count = Rs_City.RecordCount              '得到动态数组的元素个数
      redim Arr_City(count)                    '重新初始化动态数组
      i = 0
      do while not Rs_City.EOF 
        New_Str = ""
        theId   = Rs_City("Id")                '得到城市Id
        theCId  = Rs_City("CId")               '得到省的Id
        theName = Rs_City("Name")              '得到城市的名字
        New_Str = theCId&","&theId&","&theName '组合成一个字符串
        Arr_City(i) = New_Str                  '给数组赋值
        i = i +1
        Rs_City.MoveNext 
      loop
      
      '动态数组的创建到此为止
      
      CloseRs(Rs_City)
      Conn.Close
      set Conn = Nothing  '然后把上边动态生成的数组Arr_City赋值给javascipt中的一个数组:All_City
      Response.Write "<script language = javascript>"
      Response.Write "  var All_City = new Array("&count&");" 
      for i = lbound(Arr_City) to ubound(Arr_City)-1
        Response.Write "All_City["&i&"] = '"&Arr_City(i)&"';"
      next
      Response.Write "</script>"
      '数组赋值到此为止
      
     '产生一个空的select,用来存放动态生成的城市
    %>
    <select name = City id = City>
    </select>
    <% '到此为止 %>
    </center>
    </body><script language = javascript>
          
      function ChangeProvince(id)
      {
        theProvinceId =  id.options[id.selectedIndex].value; //得到所选择省的Id
        
        for (j = document.all.City.length;j>=0;j--)          //去掉原来城市select中的城市
          document.all.City.remove(j);
          
        for (i = 0 ;i<<%=count%>;i++)
        {
           theCity = All_City[i].split(",");                 //利用函数split生成一个数组theCity,内容类似为("1","2","济南")
          if (theProvinceId == theCity[0])
          {
            document.all.City.options.add(new Option(theCity[2])); //第二个select动态增加内容       
          }
        }
        
      }
      
    </script>   
      

  3.   

    lsrzm(月影飞鸿--我要分、分、分.....) 的这个例子我已看过,可是运行时发生错误了我要求用jsp来实现的
      

  4.   

    fason(阿信) 的例子我也看过,你的那个例子是从一个表中来提取数据,而我现在需要从两个表中提取数据,帮忙再给我写一个吧!!分可以再加!!!!
      

  5.   

    我写的程序的一部分 var ProjectSet = new SimpleAccess();SimpleAccess是一个类,不在以下程序中,ProjectSet是一个ADODB.RecordSet,关系不大,BindingSelect.DataSource是一个ADODB.RecordSet对象就可以了。一时急用写得不好,后来也没时间改,献丑了,:)
    <%@ language="Jscript"%>
    <%
    function BindingSelect()
    {
    this.Id = "";
    this.DataTextField = "";
    this.DataValueField = "";
    this.DataSource = null;
    this.SelectedValue = "";
    this.RaiseEvent = false;
    this.CustomCSS = "";
    this.Enabled = true; this.Show = BindingSelect_Show;
    this.DataBind = BindingSelect_DataBind;
    }function BindingSelect_Show()
    {
    Response.Write('<select');
    if ( this.CustomCSS == "" )
    {
    Response.Write(' style="width:130px;"');
    }
    else
    {
    Response.Write(' style="' + this.CustomCSS + '"');
    }
    if ( !this.Enabled )
    {
    Response.Write(' disabled');
    }
    Response.Write(' id="' + this.Id + '" name="' + this.Id + '"');
    if ( this.RaiseEvent )
    {
    Response.Write(' onchange="' + this.Id + '_onchange()"');
    }
    Response.Write('>' + "\n");
    Response.Write('<option value="">--------</option>' + "\n");
    Response.Write('</select>');
    }function BindingSelect_DataBind()
    {
    Response.Write('<select');
    if ( this.CustomCSS == "" )
    {
    Response.Write(' style="width:130px;"');
    }
    else
    {
    Response.Write(' style="' + this.CustomCSS + '"');
    }
    Response.Write(' id="' + this.Id + '" name="' + this.Id + '"');
    if ( !this.Enabled )
    {
    Response.Write(' disabled');
    }
    if ( this.RaiseEvent )
    {
    Response.Write(' onchange="' + this.Id + '_onchange()"');
    }
    Response.Write('>' + "\n");
    Response.Write('<option value="">--------</option>' + "\n");
    while ( !this.DataSource.BOF && !this.DataSource.EOF )
    {
    if ( (this.DataSource(this.DataValueField)+"").replace(/^( *)(.*[^ ])( *)$/,"$2") == this.SelectedValue )
    {
    Response.Write('<option selected value="' + (this.DataSource(this.DataValueField)+"").replace(/^( *)(.*[^ ])( *)$/,"$2") + '">' + (this.DataSource(this.DataTextField)+"").replace(/^( *)(.*[^ ])( *)$/,"$2") + '</option>' + "\n");
    }
    else
    {
    Response.Write('<option value="' + (this.DataSource(this.DataValueField)+"").replace(/^( *)(.*[^ ])( *)$/,"$2") + '">' + (this.DataSource(this.DataTextField)+"").replace(/^( *)(.*[^ ])( *)$/,"$2") + '</option>');
    }
    this.DataSource.MoveNext();
    }
    Response.Write('</select>');
    }
    %><TR>
    <TD align="center">部门</TD>
    <TD bgcolor="#fff4dd"><%
    var WinSet = new SimpleAccess();
    WinSet.QueryString = "select * from SYS_DEPARTMENT where not department_id=0 and not department_id=40";
    WinSet.ExecuteSelectQuery(); var Win = new BindingSelect();
    Win.DataSource = WinSet.QueryResult;
    Win.Id = "ReportWin";
    Win.DataTextField = "DEPARTMENT_NAME";
    Win.DataValueField = "DEPARTMENT_ID";
    Win.RaiseEvent = true;
    Win.SelectedValue = Request("ReportWin")+"";
    Win.DataBind();
    %></TD>
    <TD align="center">事项</TD>
    <TD bgcolor="#fff4dd"><%
    var ProjectSet = new SimpleAccess();
    ProjectSet.QueryString = "select * from GOV_PROJECT where DEPARTMENT_ID = '" + Request("ReportWin") + "'";
    ProjectSet.ExecuteSelectQuery(); var Project = new BindingSelect();
    Project.DataSource = ProjectSet.QueryResult;
    Project.Id = "ReportProject";
    Project.DataTextField = "PROJECT_NAME";
    Project.DataValueField = "PROJECT_ID";
    Project.RaiseEvent = true;
    Project.SelectedValue = Request("ReportProject")+"";
    if ( Request("ReportWin")+"" != "" )
    Project.DataBind();
    else
    Project.Show();
    %></TD>
    </TR>
      

  6.   

    1、把province的id、pro_name分别作为列表框1的value,text,
    <select name="province" id="province" onChange="chg(document.all.city,this.options[this.selectedIndex].value);">
    ...
    </select>
    2、利用Javascript建立二位数组,数组内容由数据库取出,循环生成,结果类似:
    <script>
    var  pro_array=new Array();
    var pro_array_val=new Array();
    var pro_array[0]=new Array();
    var pro_array_val[0]=new Array();
    pro_array[0][0]="成都";
    pro_array_val[0][0]=1;
    pro_array[0][1]="乐山";
    pro_array_val[0][1]=2;
    ...
    var pro_array[1]=new Array();
    pro_array[1][0]="杭州";
    pro_array_val[1][0]=5;
    pro_array[1][1]="宁波";
    pro_array_val[1][1]=6;
    ...
    //上面的pro_array[0][0]前一个0表示province的id,后面的表示city的index,不是id.
    //Change function
    function chg(obj,pro_id)
    {
    remove(obj);
    for (var i=0;i<pro_array[pro_id].length;i++)
    {
    set_menu(obj,pro_array_val[pro_id][i],pro_array[pro_id][i]);
    }
    }
    //增加函数
    function set_menu(obj_sel,sel_val,sel_txt)
    {
    var oOption = document.createElement("OPTION");
    obj_sel.options.add(oOption);
    oOption.innerText = sel_txt;
    oOption.value =sel_val;
    }
    //删除函数
    function remove(obj_sel)
    {
    var obj_sel_len=obj_sel.length;
    for (var del_m=obj_sel_len;del_m>=0;del_m--)//从最后一条开始删除。
    {
    obj_sel.remove(del_m);
    obj_sel_len=obj_sel.length;
    }
    }
    </script>
    3、在BODY增加
    <body onLoad="chg(document.all.city,pro_id0);">