Nclass.asp
上传用户:xxtaishan
上传日期:2022-01-02
资源大小:4063k
文件大小:6k
源码类别:

IP电话/视频会议

开发平台:

ASP/ASPX

  1. <!--#include file="../../inc/conn.asp"-->
  2. <!--#include file="../../inc/func.asp"-->
  3. <%
  4. dim rs
  5. if request.form("submit")="添加" then
  6. if request.form("classid")="" then
  7. call showerr("系统提示:请先选择一级类别名称!")
  8. end if
  9. if request.form("nclassname")="" then
  10. call showerr("系统提示:请填写二级类别名称!")
  11. end if
  12. set rs=server.createobject("adodb.recordset")
  13. rs.open "nclass",conn,1,3
  14. rs.addnew
  15. rs("nclassname")=request.form("nclassname")
  16. rs("classid")=request.form("classid")
  17. rs.update
  18. call showmsg("系统提示:类别增加成功","?")
  19. end if
  20. if request.form("submit")="修改" then
  21. if request.form("nclassid")="" then
  22. call showerr("系统提示:请选择二级类别!")
  23. else
  24. if request.form("nclassn2")="" then
  25. call showerr("系统提示:二级类别名称不能为空!")
  26. end if
  27. set rs=server.createobject("adodb.recordset")
  28. rs.open "nclass where id="&request.form("nclassid"),conn,1,3
  29. rs("nclassname")=request.form("nclassn2")
  30. rs.update
  31. call showmsg("系统提示:类别修改成功","?")
  32. end if
  33. end if
  34. if request("submit")="删除" then
  35. if request("nclassid")="" then
  36. call showerr("系统提示:请选择类别!")
  37. end if
  38. conn.execute("delete from nclass where id="&request("nclassid"))
  39. call showmsg("系统提示:类别删除成功","?")
  40. end if
  41. sql="select * from nclass order by id asc"
  42. set rs=conn.execute(sql)
  43. %>
  44. <html>
  45. <head>
  46. <title></title>
  47. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  48. <script>
  49. var onecount;
  50. onecount=0;
  51. subcat = new Array();
  52. <%
  53. dim count
  54. count=0
  55. do while not rs.eof 
  56. %>
  57. subcat[<%=count%>] = new Array("<%= trim(rs("nclassname"))%>","<%= trim(rs("classid"))%>","<%= trim(rs("id"))%>");
  58. <%
  59. count = count + 1
  60. rs.movenext
  61. loop
  62. rs.close
  63. %>
  64. onecount=<%=count%>;
  65. function changelocation(locationid)
  66.     {
  67.     document.form1.nclassid.length = 0; 
  68.     var locationid=locationid;
  69.     var i;
  70.     for (i=0;i < onecount; i++)
  71.         {
  72.             if (subcat[i][1] == locationid)
  73.             { 
  74.                 document.form1.nclassid.options[document.form1.nclassid.length] = new Option(subcat[i][0], subcat[i][2]);
  75.             }        
  76.         }
  77.         
  78.     } 
  79. function report()
  80. {
  81. var options_string = "";
  82. var the_select = window.document.form1.nclassid;
  83. for (loop=0; loop < the_select.options.length; loop++)
  84. {
  85. if (the_select.options[loop].selected == true)
  86. {
  87.  options_string += the_select.options[loop].text;
  88. }
  89. }
  90. window.document.form1.nclassn2.value=options_string;
  91. }
  92. </script>
  93. <link href="../Images/style.css" rel="stylesheet" type="text/css">
  94. <style type="text/css">
  95. <!--
  96. .style1 {color: #FFFFFF}
  97. -->
  98. </style>
  99. </head>
  100. <body>
  101. <form name="form1" method="post" action="">
  102.   <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
  103.     <tr>
  104.       <td width="100%">
  105.         <div align="center"></div></td>
  106.     </tr>
  107.     <tr>
  108.       <td width="100%">
  109.         <table width="100%" border="1" cellspacing="0" cellpadding="2" bordercolordark="#ffffff" bordercolorlight="#000000">
  110.           <tr>
  111.             <td height="25" bgcolor="#23458B"><span class="style1">添加二级类别:</span></td>
  112.           </tr>
  113.           <tr>
  114.             <td height="25"><%
  115. sql="select * from class order by id asc"
  116. set rs=conn.execute(sql)
  117. if not rs.eof then
  118. %>
  119.             选择类别:
  120.               <select name="classid" id="select">
  121.                 <option value="">--请选择类别--</option>
  122.                 <%do while not rs.eof%>
  123.                 <option value="<%=rs("id")%>"><%=rs("classname")%></option>
  124.                 <%rs.movenext
  125.               loop
  126.             %>
  127.               </select>
  128.             填写二级类别名称:
  129.             <input name="nclassname" type="text" id="nclassname2" size="15">
  130.             <input type="submit" name="Submit" value="添加">
  131.             <%else%>
  132.             没有任何类别,请添加类别!
  133.             <%end if%></td>
  134.           </tr>
  135.         </table>
  136.         <br>
  137.         <table width="100%" border="1" cellspacing="0" cellpadding="2" bordercolordark="#ffffff" bordercolorlight="#000000">
  138.           <tr>
  139.             <td height="25" bgcolor="#23458B"><span class="style1">对类别进行添加和删除:</span></td>
  140.           </tr>
  141.           <tr>
  142.             <td height="50">
  143.               <%
  144.   dim selclass
  145. sql="select * from class"
  146. set rs=conn.execute(sql)
  147. if not rs.eof then
  148. %>
  149.             选择类别:
  150.             <select name="classid2" id="classid2" onChange="changelocation(document.form1.classid2.options[document.form1.classid2.selectedIndex].value)">
  151.               <option value="">--请选择类别--</option>
  152.   <%
  153.   if not rs.eof then
  154. selclass=rs("id")
  155.   %>
  156.    <option value="<%=rs("id")%>" selected><%=rs("classname")%></option>
  157.    <%
  158.     rs.movenext
  159.    end if%>
  160.               <%do while not rs.eof%>
  161.               <option value="<%=rs("id")%>"><%=rs("classname")%></option>
  162.               <%
  163.   rs.movenext
  164.               loop
  165.             %>
  166.             </select>
  167.             <select name="nclassid" onChange="report();">
  168. <%
  169. sql="select * from nclass where classid="&selclass&" order by id asc"
  170. set rs=conn.execute(sql)
  171. if not(rs.eof and rs.bof) then
  172. do while not rs.eof%>
  173.               <option value="<%=rs("id")%>"><%=rs("nclassname")%></option>
  174.               <% rs.movenext
  175. loop
  176. end if
  177. %>
  178.             </select>
  179.             <br>
  180.             类别名称:
  181.             <input name="nclassn2" type="text" id="nclassn2">
  182.             <input type="submit" name="Submit" value="修改">
  183.             <input type="button" name="Submit" value="删除" onClick="nclass_del();">
  184.             <%else%>
  185.             没有任何类别,请添加类别!
  186.             <%end if%>
  187.             </td>
  188.           </tr>
  189.       </table></td>
  190.     </tr>
  191.   </table>
  192. </form>
  193. <script language="JavaScript">
  194. function nclass_del()
  195. {
  196. if(confirm('* 确定删除类别吗?'))
  197. {
  198. form1.action="?submit=删除&nclassid="+document.form1.nclassid.value;
  199. form1.submit();
  200. }
  201. }
  202. </script>
  203. </body>
  204. </html>