级联下拉列表

 

<%
dim count
set rs7=server.createobject("adodb.recordset")
rs7.Source= "select * from SmallClass order by zs_id desc"
rs7.open rs7.Source,conn,1,1
%>
 
 
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
        <%
        count = 0             
        do while not rs7.eof
        %>
subcat[<%=count%>] = new Array("<%=rs7("SmallClassName")%>","<%=rs7("bigclassname")%>","<%=rs7("SmallClassname")%>");
        <%
        count = count + 1
        rs7.movenext
        loop
        rs7.close
              set rs7=nothing
        %>
onecount=<%=count%>;
 
function changelocation(locationid)
    {
    document.form1.smallclassname.length = 0;
 
    var locationid=locationid;
    var i;
 
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            {
 
                document.form1.smallclassname.options[document.form1.smallclassname.length] = new Option(subcat[i][0], subcat[i][2]);
            }       
        }
       
    }   
</script>
 
 
请选择栏目:
        <select name="bigclassname" onChange="changelocation(document.form1.bigclassname.options[document.form1.bigclassname.selectedIndex].value)" size="1">
          <option selected value="<%=bigclassname%>"><%=bigclassname%></option>
          <%        
set rs8=server.CreateObject("ADODB.RecordSet")
rs8.Source="select * from BigClass order by zs_id"
rs8.Open rs8.Source,conn,1,1
        do while not rs8.eof
        %>
          <option value="<%=rs8("bigclassname")%>"><%=rs8("bigclassname")%></option>
          <%
        rs8.movenext
        loop
        rs8.close
              set rs8=nothing
        %>
        </select>
        小类
        <select name="smallclassname">
          <option selected value="<%=smallclassname%>"><%=smallclassname%></option>
          <%        
set rs8=server.CreateObject("ADODB.RecordSet")
rs8.Source="select * from smallclass where bigclassname='"&bigclassname&"' order by zs_id"
rs8.Open rs8.Source,conn,1,1
        do while not rs8.eof
        %>
          <option value="<%=rs8("smallclassname")%>"><%=rs8("smallclassname")%></option>
          <%
        rs8.movenext
        loop
        rs8.close
              set rs8=nothing
        %>
        </select>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值