| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 419 人关注过本帖
标题:asp三级联动无法不能选择,下一级的,不知道怎么修改代码
只看楼主 加入收藏
neihe
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2011-11-6
结帖率:0
收藏
 问题点数:0 回复次数:1 
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
liuyudong_a
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-3-23
收藏
得分:0 
回复 楼主 neihe参考参考这个
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>资料录入页面</title>
<script language="JavaScript">
function bb(num){
city = new Array();
city[1]= new Array("西安","1","1");
city[2]= new Array("咸阳","2","1");
city[3]= new Array("宝鸡","3","1");
city[4]= new Array("洛阳","4","2");
city[5]= new Array("郑州","5","2");
city[6]= new Array("开封","6","2");
city[7]= new Array("成都","7","3");
city[8]= new Array("绵阳","8","3");
city[9]= new Array("广元","9","3");
//把数组的值用数据库读出
document.form1.s1.length = 0;
document.form1.s2.length = 0;
document.form1.s2.options[0]= new Option("还没有市","0");
document.form1.s1.options[0]= new Option("请选择市","0");
j=1;
for(i=1;i<=9;i++)
{ if(city[i][2]==num)
{document.form1.s1.options[document.form1.s1.length]= new Option(city[i][0],city[i][1]);}
j++}
}
function cc(num){
city = new Array();
city[1]= new Array("未央区","1","1");
city[2]= new Array("雁塔区","2","1");
city[3]= new Array("灞桥区","3","1");
city[4]= new Array("秦都区","4","2");
city[5]= new Array("渭城区","5","2");
city[6]= new Array("渭滨区","6","3");
city[7]= new Array("金台区","7","3");
city[8]= new Array("陈仓区","8","3");
city[9]= new Array("老城区","9","4");
city[10]= new Array("涧西区","10","4");
city[11]= new Array("西工区","11","4");
city[12]= new Array("中原区","12","5");
city[13]= new Array("惠济区","13","5");
city[14]= new Array("金水区","14","5");
city[15]= new Array("龙亭区","15","6");
city[16]= new Array("金明区","16","6");
city[17]= new Array("鼓楼区","17","6");
city[18]= new Array("青羊区","18","7");
city[19]= new Array("金牛区","19","7");
city[20]= new Array("武侯区","20","7");
city[21]= new Array("游仙区","21","8");
city[22]= new Array("培城区","22","8");
city[23]= new Array("朝天区","23","9");
city[24]= new Array("元坝区","24","9");
//把数组的值用数据库读出
document.form1.s2.length = 0;
document.form1.s2.options[0]= new Option("请选择区","0");
j=1;
for(i=1;i<=24;i++)
{ if(city[i][2]==num)
{document.form1.s2.options[document.form1.s2.length]= new Option(city[i][0],city[i][1]);}
j++}
}
</script>

<script language="javascript">
function show(){
    var obj=document.getElementByid("s2");
    alert(obj.value);
}
</script>
</head>

<body>
<form method="POST" action="<%=MM_editAction%>" name="form1" >
  <table align="center"  >
    <tr valign="baseline">
      <td nowrap align="right"><span class="STYLE4">籍贯:</span></td>
      <td>
      <select name="ss" class="STYLE4" onChange="bb(document.form1.ss.options[document.form1.ss.selectedIndex].value)" >
      <option value="0">请选择省</option>
      <option value="1">陕西</option>
      <option value="2">河南</option>
      <option value="3">四川</option>
      </select>
      <select name="s1" class="STYLE4" onChange="cc(document.form1.s1.options[document.form1.s1.selectedIndex].value)">
      </select>
      <select name="s2"  class="STYLE4" id="s2" onchange="show()">
      </select>
      </td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
</body>
</html>


2011-11-13 10:55
快速回复:asp三级联动无法不能选择,下一级的,不知道怎么修改代码
数据加载中...
 
   



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

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