标题:asp三级联动无法不能选择,下一级的,不知道怎么修改代码
取消只看楼主
neihe
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2011-11-6
结帖率:0
 问题点数:0 回复次数:0 
asp三级联动无法不能选择,下一级的,不知道怎么修改代码
<script language="JavaScript">
<!--
<%
Dim count2,rsClass2,sqlClass2  
set rsClass2=server.createobject("adodb.recordset")  
sqlClass2="select * from LY_bclass"  
rsClass2.open sqlClass2,conn,1,1  
%>  
var subval2 = new Array();
<%  
count2 = 0  
do while not rsClass2.eof
%>  
subval2[ <%=count2%>] = new Array(' <%=rsClass2("bclassid")%>',' <%=rsClass2("classid")%>',' <%=rsClass2("bclassen")%>')   
<%  
count2 = count2 + 1  
rsClass2.movenext  
loop  
rsClass2.close  
%>
<%  
 Dim count3,rsClass3,sqlClass3  
 set rsClass3=server.createobject("adodb.recordset")  
 sqlClass3="select * from LY_sclass"  
 rsClass3.open sqlClass3,conn,1,1  
%>
var subval3 = new Array();
<%  
count3 = 0  
do while not rsClass3.eof  
%>
subval3[ <%=count3%>] = new Array(' <%=rsClass3("nclassid")%>','<%=rsClass3("bclassid")%>',' <%=rsClass3("nclassen")%>')   
<%  
count3 = count3 + 1  
rsClass3.movenext  
loop  
rsClass3.close  
%>

function changepro(city,pro)
        {
        var city=city;
        var pro=document.getElementById(pro).value;
        var i;
        document.getElementById(city).length=1;
            for (i=0;i<subval2.length;i++){
            if (subval2[i][1]==pro){
            document.getElementById(city).options[document.getElementById(city).length]=new Option(subval2[i][0], subval2[i][0]);
            }        
            }
        
        }
//定义函数:用于联动市 和 县 两级-----county 为县级下拉框的id名,city为市下拉框的id 号。 用法:onChange="changecity('市id名','县id名');"///////////////////        
        function changecity(county,city)
        {
        var county=county;
        var city=document.getElementById(city).value;
        var j;
        document.getElementById(county).length=1;
            for (j=0;j <subval3.length;j++){
            if (subval3[j][1]==city){
            document.getElementById(county).options[document.getElementById(county).length]=new Option(subval3[j][0], subval3[j][0]);
            }        
            }
        
        }
 //-->
</script>
<form name="form1" method="post" action="test1.asp">
<table width="100%" cellspacing="5">
  <tr>
    <td width="15%">Game: </td>
    <td width="85%">
    <%  
    Dim count1,rsClass1,sqlClass1  
    set rsClass1=server.createobject("adodb.recordset")  
    sqlClass1="select * from LY_class"  
    rsClass1.open sqlClass1,conn,1,1  
    %>  
     <select name="city1" id="city1" onChange="changepro('city2','city1');">  
      <option>-- Please select the game --</option>
      <%  
      count1 = 0  
      do while not rsClass1.eof  
      response.write" <option value="&rsClass1("classid")&">"&rsClass1("classen")&" </option>"  
      count1 = count1 + 1  
      rsClass1.movenext  
      loop  
      rsClass1.close  
      %>   
      </select>
   </td>
  </tr>
  <tr>
    <td>Server: </td>
    <td>
   
    <select name="city2" id="city2" onChange="changecity('city3','city2');">
      <option>-- Please select the server --</option>
      </select>
    </td>
  </tr>
  <tr>
    <td>Product:</td>
    <td>
     <select name="city3" id="city3">
      <option>-- Please select the product --</option>
      </select>
   
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>
2011-11-11 14:58



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-354976-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.052569 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved