您的位置:首页 > 编程语言 > ASP

ASP二级分类联动菜单

2008-07-23 17:18 387 查看
<!--#include file="conn.asp"-->

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<%
A = request.Form("anclassid")
B = request.Form("Nclassid")
if request.Form("Submit")="提交" then
   response.Write  "a="&A
   response.Write  "<br>b="&B
   response.End()
end if   

dim count

set rs=server.createobject("adodb.recordset")
'--------取出小类里的数据,Nclassidorder:小类在大类里的ID号
rs.open "select * from class order by id ",conn,1,1%>

<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
   count = 0
   do while not rs.eof
%>
<!---读出数据存入数组,第一位:class_name是小类名称,第二位:v_school是小类在大类里的ID号,三位:小类ID----->
subcat[<%=count%>] = new Array("<%= trim(rs("class_name"))%>","<%= rs("v_school")%>","<%= rs("id")%>");
<%
        count = count + 1
        rs.movenext
        loop
        rs.close
%>
        
onecount=<%=count%>;

function changelocation(locationid)
    {
    document.myform.Nclassid.length = 0;

    var locationid=locationid;
    var i;
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            { //这句不是很理解
             document.myform.Nclassid.options[document.myform.Nclassid.length] = new Option(subcat[i][0], subcat[i][2]);
            }        
        }
        
    }    
</script>
<body>
<table cellpadding="3" cellspacing="1" border="0" width="100%" class="tableBorder" align=center>
  <tr height=25>
    <th class="tableHeaderText" colspan=6 height=25>添加新商品</th>    
  </tr>
  <tr>
   <td class="forumRowHighlight" >
    <table align=center>
        <form name="myform" method="post" action="test.asp" OnSubmit="return checkkk()" >
          <tr>
            <td width="8%"> </td>

            <td colspan="2">
              <p>
                <%
    rs.open "select * from school order by school_id",conn,1,1
    '-----------列出大类数据
    if rs.eof and rs.bof then
    response.write "请先添加栏目。"
    response.end
    else
%>
              大类:
  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息