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

<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

<%@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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值