大类表:
class
字段
id
classname小类表:
nclass
字段
id
nclassname
classid相关代码<!--#include file="conn.asp"-->
<%
dim rs
set rs=conn.execute("select * from nclass order by id asc")
%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>
var onecount;
onecount=0;
subcat = new Array();
<%
dim count
count=0
do while not rs.eof 
%>
subcat[<%=count%>] = new Array("<%= trim(rs("nclassname"))%>","<%= trim(rs("classid"))%>","<%= trim(rs("id"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;function changelocation(locationid)
    {
    document.form1.nclassid.length = 0;     var locationid=locationid;
    var i;
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            { 
                document.form1.nclassid.options[document.form1.nclassid.length] = new Option(subcat[i][0], subcat[i][2]);
            }        
        }
        
    } 

function report()
{
var options_string = "";
var the_select = window.document.form1.nclassid;
for (loop=0; loop < the_select.options.length; loop++)
{
if (the_select.options[loop].selected == true)
{  options_string += the_select.options[loop].text;
}
}
window.document.form1.nclassn2.value=options_string;
}</script>
<link href="../Images/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
</head><body>
<form name="form1" method="post" action="">
  <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
    <tr>
      <td width="100%">
        <div align="center"></div></td>
    </tr>
    <tr>
      <td width="100%">
        <table width="100%" border="1" cellspacing="0" cellpadding="2" bordercolordark="#ffffff" bordercolorlight="#000000">
          <tr>
            <td height="25" bgcolor="#23458B"><span class="style1">添加二级类别:</span></td>
          </tr>
          <tr>
            <td height="25"><%
sql="select * from class order by id asc"
set rs=conn.execute(sql)
if not rs.eof then
%>
            选择类别:
              <select name="classid" id="select" onChange="report();">
                <option value="">--请选择类别--</option>
                <%do while not rs.eof%>
                <option value="<%=rs("id")%>"><%=rs("classname")%></option>
                <%rs.movenext
              loop
            %>
              </select>
            填写二级类别名称:
            <input name="nclassname" type="text" id="nclassname2" size="15">
            <input type="submit" name="Submit" value="添加">
            <%else%>
            没有任何类别,请添加类别!
            <%end if%></td>
          </tr>
        </table>
        <br>
        <table width="100%" border="1" cellspacing="0" cellpadding="2" bordercolordark="#ffffff" bordercolorlight="#000000">
          <tr>
            <td height="25" bgcolor="#23458B"><span class="style1">对类别进行添加和删除:</span></td>
          </tr>
          <tr>
            <td height="50">
              <%
  dim selclass
sql="select * from class"
set rs=conn.execute(sql)
if not rs.eof then
%>
            选择类别:
            <select name="classid2" id="classid2" onChange="changelocation(document.form1.classid2.options[document.form1.classid2.selectedIndex].value)">
              <option value="">--请选择类别--</option>
  <%
  if not rs.eof then
selclass=rs("id")
  %>
   <option value="<%=rs("id")%>" selected><%=rs("classname")%></option>
   <%
    rs.movenext
   end if%>
              <%do while not rs.eof%>
              <option value="<%=rs("id")%>"><%=rs("classname")%></option>
              <%
  rs.movenext
              loop
            %>
            </select>
            <select name="nclassid" onChange="report();">
<%
sql="select * from nclass where classid='"&selclass&"' order by id asc"
set rs=conn.execute(sql)
if not(rs.eof and rs.bof) then do while not rs.eof%>
              <option value="<%=rs("id")%>"><%=rs("nclassname")%></option>
              <% rs.movenext
loop
end if
%>
            </select>
            <br>
            类别名称:
            <input name="nclassn2" type="text" id="nclassn2">
            <input type="submit" name="Submit" value="修改">
            <input type="button" name="Submit" value="删除" onClick="nclass_del();">
            <%else%>
            没有任何类别,请添加类别!
            <%end if%>
            </td>
          </tr>
      </table></td>
    </tr>
  </table>
</form>
</body>
</html>