• ASP+JS三级连动下拉框



    <%
    'OK工作室 http://ok123.k989.com
    'sort   一级分类表:sort_id,sort_name
    'nsort  二级分类表:nsort_id,sort_id,nsort_name
    'nnsort 三级分类表:nnsort_id,nsort_id,nnsort_name
    %>
    <!--#include file="conn.asp"-->
    <%
    dim count
    set rs=server.createobject("adodb.recordset")
    sql="select * from  nsort"
    rs.open sql,conn,1,3
    %>
    <script language = "JavaScript">
    var onecount;
    onecount=0;
    subcat = new Array();
            <%
            count = 0
            do while not rs.eof
            %>
    subcat[<%=count%>] = new Array("<%= trim(rs("nsort_name"))%>","<%= trim(rs("sort_id"))%>","<%= trim(rs("nsort_id"))%>");
            <%
            count = count + 1
            rs.movenext
            loop
            rs.close
            %>
    onecount=<%=count%>;

    function changelocation(locationid)
        {
        document.form.nsort_id.length = 0;

        var locationid=locationid;
     document.form.nsort_id.options[0] = new Option('二级分类', '');
        var i;
        for (i=0;i < onecount; i++)
            {
                if (subcat[i][1] == locationid)
                {
                    document.form.nsort_id.options[document.form.nsort_id.length] = new Option(subcat[i][0], subcat[i][2]);
                }       
            }
           
        }   
    </script>

    <%
    sql = "select * from nnsort"
    rs.open sql,conn,1,1
    %>
    <script language = "javascript">
    var onecount2;
    onecount2=0;
    subcat2 = new Array();
    <%
    count2 = 0
    do while not rs.eof
    %>
    subcat2[<%=count2%>] = new Array("<%= trim(rs("nnsort_name"))%>","<%= trim(rs("nsort_id"))%>","<%= trim(rs("nnsort_id"))%>");
    <%
    count2 = count2 + 1
    rs.movenext
    loop
    rs.close
    %>
    onecount2=<%=count2%>;

    function changelocation2(locationid)
    {
    document.form.nnsort_id.length = 0;

    var locationid=locationid;
    var j;
    document.form.nnsort_id.options[0] = new Option('三级分类','');
    for (j=0;j < onecount2; j++)
    {
    if (subcat2[j][1] == locationid)
    {
    document.form.nnsort_id.options[document.form.nnsort_id.length] = new Option(subcat2[j][0], subcat2[j][2]);
    }
    }

    }
    </script>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>JS三级连动下拉框</title>
    </head>

    <body>
    <form name="form" method="post" action="">
      <select name="sort_id" onChange="changelocation(document.form.sort_id.options[document.form.sort_id.selectedIndex].value);changelocation2(document.form.nsort_id.options[document.form.nsort_id.selectedIndex].value);">
        <option selected>一级分类</option>
     <%
      sql="select * from sort"
      rs.open sql,conn,1,1
      do while not rs.eof
      %>
      <option value="<%=rs("sort_id")%>"><%=rs("sort_name")%></option>
      <%
        rs.movenext
      loop
      rs.close
      %>
      </select>
      <select name="nsort_id" onChange="changelocation2(document.form.nsort_id.options[document.form.nsort_id.selectedIndex].value);">
        <option selected>二级分类</option>
      </select>
      <select name="nnsort_id">
        <option selected>三级分类</option>
      </select>
    </form>
    </body>
    </html>
    <%
    set rs=nothing
    conn.close
    set conn=nothing
    %>

  • 相关阅读:
    caffe的python接口学习(5):生成deploy文件
    Flutter -------- 新手 WanAndroid 项目练习
    android -------- GifView 显示gif图片
    android -------- java.net.UnknownServiceException
    Flutter ------- WebView加载网页
    Flutter -------- 解析JSON数据
    Flutter -------- Http库 网络请求封装(HttpController)
    android ------ 实现高德定位并获取相应信息 ( 最新版高德SDK 和 Android SDK版本)
    Flutter -------- dio网络请求
    Flutter -------- Http库实现网络请求
  • 原文地址:https://www.cnblogs.com/winner/p/417240.html
Copyright © 2020-2023  润新知