下拉框二级分类关联

<!--#include file="check.asp"-->
<!--#include file="conn.asp"-->
<%
If Request.QueryString("style")="del" Then
   on error resume next
   conn.execute("delete * from [classname] where classname='"&Request.Form("classname2")&"'")
   conn.execute("delete * from [imgbook] where classname='"&Request.Form("classname2")&"'")
ElseIf Request.QueryString("style")="modify" Then
   classname=Trim(Request.Form("newclassname"))
   If classname="" Then
      Response.Write("<script language=javascript>alert('非法操作!!!');history.back()</script>")
      Response.End()
   End If
   if instr(classname,"'") or instr(classname,"select") or instr(classname,"in") or instr(classname,"from") or instr(classname,"len") or instr(classname,"where") or instr(classname,"or") or instr(classname,"and") then
     Response.Write("<script language=javascript>alert('包含非法字符!!!');history.back();</script>")
  Response.End
   end if                    
   on error resume next
   conn.execute("update [classname] set classname='"&classname&"' where classname='"&Request.Form("classname")&"'")
   conn.execute("update [imgbook] set classname='"&classname&"' where class='"&Request.Form("classname")&"'")
End If
If Request.QueryString("style")="add" Then
  classname=Trim(Request.Form("classname3"))
  if instr(classname,"'") or instr(classname,"select") or instr(classname,"in") or instr(classname,"from") or instr(classname,"len") or instr(classname,"where") or instr(classname,"or") or instr(classname,"and") then
    Response.Write("<script language=javascript>alert('包含非法字符!!!');history.back();</script>")
 Response.End
  end if                    
   conn.execute("insert into [classname] (classname) values ('"&classname&"')")
   Response.Write("<script language=javascript>alert('成功填加.请返回!');window.location.replace('classmana.asp')</script>")
End If
If Request.QueryString("style")="adds" Then
  bigclass=Replace(Trim(Request.Form("bigclass")),"'","")
  smallclass=Replace(Trim(Request.Form("smallclass")),"'","")
  if instr(smallclass,"'") or instr(smallclass,"select") or instr(smallclass,"in") or instr(smallclass,"from") or instr(smallclass,"len") or instr(smallclass,"where") or instr(smallclass,"or") or instr(smallclass,"and") then
    Response.Write("<script language=javascript>alert('包含非法字符!!!');history.back();</script>")
 Response.End
  end if
  if smallclass="" then     
     Response.Write("<script language=javascript>alert('请填写小类名称!!!');history.back();</script>")
  Response.End     
  end if        
   conn.execute("insert into [smallclass] (smallclassname,bigclassname) values ('"&smallclass&"','"&bigclass&"')")
   Response.Write("<script language=javascript>alert('成功填加.请返回!');window.location.replace('classmana.asp')</script>")
elseif Request.QueryString("style")="modifys" then
    bigclass=Replace(Trim(Request.Form("bigclass")),"'","")
  smallclass=Replace(Trim(Request.Form("smallclass")),"'","")
  smallclassname=Replace(Trim(Request.Form("smallclassname")),"'","")
  if instr(smallclass,"'") or instr(smallclass,"select") or instr(smallclass,"in") or instr(smallclass,"from") or instr(smallclass,"len") or instr(smallclass,"where") or instr(smallclass,"or") or instr(smallclass,"and") then
    Response.Write("<script language=javascript>alert('包含非法字符!!!');history.back();</script>")
 Response.End
  end if
  if smallclass="" then     
     Response.Write("<script language=javascript>alert('请选择二级分类!!!');history.back();</script>")
  Response.End     
  end if        
  if smallclassname="" then     
     Response.Write("<script language=javascript>alert('请填写新小类名称!!!');history.back();</script>")
  Response.End     
  end if        
   conn.execute("update [smallclass] set smallclassname='"&smallclassname&"' where bigclassname='"&bigclass&"' and smallclassname='"&smallclass&"'")
   Response.Write("<script language=javascript>alert('修改成功.请返回!');window.location.replace('classmana.asp')</script>")
elseif Request.QueryString("style")="dels" then
    bigclass=Replace(Trim(Request.Form("bigclass")),"'","")
  smallclass=Replace(Trim(Request.Form("smallclass")),"'","")
  if instr(smallclass,"'") or instr(smallclass,"select") or instr(smallclass,"in") or instr(smallclass,"from") or instr(smallclass,"len") or instr(smallclass,"where") or instr(smallclass,"or") or instr(smallclass,"and") then
    Response.Write("<script language=javascript>alert('包含非法字符!!!');history.back();</script>")
 Response.End
  end if
  if smallclass="" then     
     Response.Write("<script language=javascript>alert('请选择二级分类!!!');history.back();</script>")
  Response.End     
  end if        
   conn.execute("delete from [smallclass] where bigclassname='"&bigclass&"' and smallclassname='"&smallclass&"'")
   Response.Write("<script language=javascript>alert('删除成功.请返回!');window.location.replace('classmana.asp')</script>")
End If
set rstmp=server.createobject("adodb.recordset")
sql = "select * from SmallClass order by SmallClassID asc"
rstmp.open sql,conn,1,1
%>
<script language = "JavaScript">
var onecount;
subcat = new Array();
        <%
        count = 0
        do while not rstmp.eof
        %>
subcat[<%=count%>] = new Array("<%= trim(rstmp("SmallClassName"))%>","<%= trim(rstmp("BigClassName"))%>","<%= trim(rstmp("SmallClassName"))%>");
        <%
        count = count + 1
        rstmp.movenext
        loop
        rstmp.close
        %>
onecount=<%=count%>;

function changelocation(locationid,frm)
    {
    eval("document."+frm+".SmallClass.length = 1;")
    var locationid=locationid;
    var i;
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            {
                eval("document."+frm+".SmallClass.options[document."+frm+".SmallClass.length] = new Option(subcat[i][0], subcat[i][2]);");
            }       
        }
    }   
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<script language=javascript>
function rusure()
{ question = confirm("此操作会影响到与本分类相关的图片...继续?")
if (question !="0")
{ parent.right.location = "newclassmana.asp" }
}
function xxg()
{
  if (form3.classname3.value=="")
   {
     alert("请写上分类的名字!!!");
  form3.classname3.focus();
  return false;
  }
  return true
  }
</script>

<body>
<br>
<br>
<%
if session("flag")>0 then
   Response.Write("<br><br><br><center>对不起。你没有权限进入此页面!!!</center>")
   Response.end
end if
%>
<table width="100%" height="221" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="10%" height="47">&nbsp;</td>
    <td><strong>图片分类管理</strong><br> <br> <font color="#FF0000">注意:分类名称不可包含以下非法字符:
      '、@、+、or、from、select、len、where、&amp;、and等</font></td>
  </tr>
  <tr>
    <td height="111" rowspan="2">&nbsp;</td>
    <td><form name="form3" method="post" action="classmana.asp?style=add" οnsubmit="return xxg()">
        <table width="100%" height="39" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="11%" height="19">&nbsp;</td>
            <td width="51%" align="center">&nbsp;</td>
            <td width="38%">&nbsp;</td>
          </tr>
          <tr>
            <td>填加分类</td>
            <td> <input name="classname3" type="text" id="classname"> &nbsp; <input type="submit" name="Submit3" value="填加">
            </td>
            <td>&nbsp;</td>
          </tr>
        </table>
      </form></td>
  </tr>
  <tr>
    <td><form name="form1" method="post" action="classmana.asp?style=modify">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="11%">&nbsp;</td>
            <td width="89%">&nbsp;</td>
          </tr>
          <tr>
            <td>更改分类</td>
            <td><select name="classname" id="select2">
                <% sql1="select * from classname"
          set rs1=conn.execute(sql1)
    do while not rs1.eof  %>
                <option value=<%=rs1("classname")%>><%=rs1("classname")%></option>
                <% i=i+1
        rs1.movenext
     loop  %>
              </select>
              该名为
              <input name="newclassname" type="text" id="newclassname2"> &nbsp;&nbsp;&nbsp;
              <input type="submit" name="Submit" value="修改" onClick="rusure();return false;">
            </td>
          </tr>
        </table>
      </form></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><form name="form2" method="post" action="classmana.asp?style=del">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="11%">&nbsp;</td>
            <td width="89%">&nbsp;</td>
          </tr>
          <tr>
            <td>删除分类</td>
            <td> <select name="classname2" id="select3">
                <% sql1="select * from classname"
          set rs1=conn.execute(sql1)
    do while not rs1.eof %>
                <option value=<%=rs1("classname")%>><%=rs1("classname")%></option>
                <% i=i+1
        rs1.movenext
    loop
rs1.close 
 %>
              </select> &nbsp; <input type="submit" name="Submit2" value="删除"  onClick="rusure();return false;"></td>
          </tr>
        </table>
      </form></td>
  </tr>
</table>
<table width="100%" height="221" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="10%" height="47">&nbsp;</td>
    <td><strong>二级分类管理</strong><br>
        <br>
        <font color="#FF0000">注意:分类名称不可包含以下非法字符: '、@、+、or、from、select、len、where、&amp;、and等</font></td>
  </tr>
  <tr>
    <td height="111" rowspan="2">&nbsp;</td>
    <td><form name="form4" method="post" action="classmana.asp?style=adds">
        <table width="100%" height="39" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="11%" height="19">&nbsp;</td>
            <td width="51%" align="center">&nbsp;</td>
            <td width="38%">&nbsp;</td>
          </tr>
          <tr>
            <td>填加分类</td>
            <td>
              一级类别
                <select name="bigclass">
<% sql1="select * from classname"
          set rs1=conn.execute(sql1)
    do while not rs1.eof %>
                <option value=<%=rs1("classname")%>><%=rs1("classname")%></option>
                <% i=i+1
        rs1.movenext
     loop
rs1.close
 %>
              </select>
              <input name="smallclass" type="text" id="smallclass">
&nbsp;
            <input type="submit" name="Submit32" value="填加">            </td>
            <td>&nbsp;</td>
          </tr>
        </table>
    </form></td>
  </tr>
  <tr>
    <td><form name="form5" method="post" action="classmana.asp?style=modifys">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="11%">&nbsp;</td>
            <td width="89%">&nbsp;</td>
          </tr>
          <tr>
            <td>更改分类</td>
            <td>一级分类
              <select name="BigClass" id="BigClass" onChange="changelocation(document.form5.BigClass.options[document.form5.BigClass.selectedIndex].value,'form5')">
                <% sql1="select * from classname"
          set rs1=conn.execute(sql1)
    do while not rs1.eof  %>
                <option value=<%=rs1("classname")%>><%=rs1("classname")%></option>
                <% i=i+1
        rs1.movenext
     loop  %>
              </select>
              二级分类
              <select name="SmallClass" id="SmallClass">
           
              </select>
              该名为
              <input name="smallclassname" type="text" id="smallclassname">
&nbsp;&nbsp;&nbsp;
              <input type="submit" name="Submit4" value="修改">
            </td>
          </tr>
        </table>
    </form></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><form name="form6" method="post" action="classmana.asp?style=dels">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="11%">&nbsp;</td>
            <td width="89%">&nbsp;</td>
          </tr>
          <tr>
            <td>删除分类</td>
            <td>
              一级分类
              <select name="BigClass" id="select4" onChange="changelocation(document.form6.BigClass.options[document.form6.BigClass.selectedIndex].value,'form6')">
                <% sql1="select * from classname"
          set rs1=conn.execute(sql1)
    do while not rs1.eof %>
                <option value=<%=rs1("classname")%>><%=rs1("classname")%></option>
                <% i=i+1
        rs1.movenext
     loop  %>
              </select>
              二级分类
              <select name="SmallClass" id="select6">
                            </select>&nbsp;
            <input type="submit" name="Submit22" value="删除">
            </td>
          </tr>
        </table>
    </form></td>
  </tr>
</table>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值