• asp js三级联动菜单,数据库版本


    <%@language=vbscript codepage=936 %>

    <!--#include file="Conn.asp"-->

    <%

    sql = "select * from smallclass order by smallclassid asc"
    set rs = conn.execute(sql)
    %>
    <script language = "JavaScript">
    var onecount;
    onecount=0;
    subcat = new Array();
            <%
            count = 0
            do while not rs.eof
            %>
    subcat[<%=count%>] = new Array("<%= trim(rs("smallclassname"))%>","<%= trim(rs("bigclassname"))%>","<%= trim(rs("smallclassname"))%>");
            <%
            count = count + 1
            rs.movenext
            loop
            rs.close
            set rs=nothing
            %>
    onecount=<%=count%>;

    function changelocation(bigclassname)
        {
        document.myform.smallclassname.length = 0;

        var bigclassname=bigclassname;
        var i;
        document.myform.smallclassname.options[0] = new Option('请选择二级分类','');
        for (i=0;i < onecount; i++)
            {
                if (subcat[i][1] == bigclassname)
                {
                    document.myform.smallclassname.options[document.myform.smallclassname.length] = new Option(subcat[i][0], subcat[i][2]);
                }       
            }
           
        }   
    </script>


    <%sql2 = "select * from minclass order by minclassid asc"
    set rs2 = conn.execute(sql2)
    %>
    <script language = "JavaScript">
    var onecount2;
    onecount2=0;
    subcat2 = new Array();
            <%
            count2 = 0
            do while not rs2.eof
            %>
    subcat2[<%=count2%>] = new Array("<%= trim(rs2("minclassname"))%>","<%= trim(rs2("smallclassname"))%>","<%= trim(rs2("minclassname"))%>");
            <%
            count2 = count2 + 1
            rs2.movenext
            loop
            rs2.close
            set rs2=nothing
            %>
    onecount2=<%=count2%>;

    function changelocation2(smallclassname)
        {
        document.myform.minclassname.length = 0;

        var smallclassname=smallclassname;
        var j;
        document.myform.minclassname.options[0] = new Option('请选择三级分类','');
        for (j=0;j < onecount2; j++)
            {
                if (subcat2[j][1] == smallclassname)
                {
                    document.myform.minclassname.options[document.myform.minclassname.length] = new Option(subcat2[j][0], subcat2[j][2]);
                }       
            }
           
        }   
    </script>

    <body onLoad="javascipt:setTimeout('loadForm()',1000);">


    <form method="POST" name="myform" onSubmit="return CheckForm();" action="ArticleSave.asp?action=add" target="_self">
            <table width="620" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
             
              <tr align="center">
                <td class="tdbg"> <table width="100%" border="0" cellpadding="0" cellspacing="2">
                    <tr>
                      <td width="151" height="22" align="right" bgcolor="#C0C0C0">所属类别:</td>
                      <td width="467" bgcolor="#E3E3E3">
                        <select name="bigclassname" onChange="changelocation(document.myform.bigclassname.options[document.myform.bigclassname.selectedIndex].value)" size="1">
            <option selected>请选择一级分类</option>
            <%
           
            sql1 = "select * from bigclass order by bigclassid asc"
            set rs1 = conn.Execute (sql1)
            do while not rs1.eof
            %>
            <option value="<%=trim(rs1("bigclassname"))%>"><%=trim(rs1("bigclassname"))%></option>
          
            <%
            rs1.movenext
            loop
            rs1.close
            set rs1 = nothing
            conn.Close
            set conn = nothing
            %>
           </select>
       
        <select name="smallclassname" onChange="changelocation2(document.myform.smallclassname.options[document.myform.smallclassname.selectedIndex].value)">                 
            <option selected value="">==所有二级分类==</option>
        </select>
           
        <select name="minclassname" size="1">                
            <option selected value="">==所有三级分类==</option>
        </select> </td>
                    </tr>
                   
        
        
                  </table></td>
              </tr>
            </table>
      
           
    </form>
      表结构如下

    BIGCLASS: bigclassid,bigclassname, 

    smallclass smallclassid ,bigclassname,smallclassname

    minclass minclassid,bigclassname,smallclassname,minclassname.

    更多内容请参考
    http://www.corange.cn/archives/2006/08/15.html

  • 相关阅读:
    plsql学习笔记1
    UC 学习之 Linux和C语言的读写比较
    theos遇到*** first argument to `word' function must be greater than 0.的错误咋办~
    最近碰到的小麻烦和解决方式~
    在iOS开发中遇到NSTextField输入后,键盘无法收回的情况咋办~~
    使用nstask的心得体会(转载)
    COCOA中NSOpenPanel的用法
    gdb关闭栈保护
    OSX中编译ideviceinstaller中遇到的问题和解决办法
    stackoverflow中一篇关于让App在后台运行的很好的讨论问答。
  • 原文地址:https://www.cnblogs.com/zerogo/p/2209392.html
Copyright © 2020-2023  润新知