AddNews.jsp
上传用户:sdtxjx
上传日期:2022-07-09
资源大小:2937k
文件大小:8k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html; charset=GBK" language="java" buffer="32kb"%>
  2. <%@ page import="dreamtime.dreamnews.*"%>
  3. <%@ include file="Session.jsp"%>
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Language" content="zh-cn">
  7. <meta http-equiv="Content-Type" content="text/html; charset=GBK">
  8. <link href="css/bodystyle.css" rel="stylesheet" type="text/css">
  9. <title>添加新闻</title>
  10. <script Language=Javascript src="js/post.js"></script>
  11. <script Language=Javascript src="js/news.js"></script>
  12. </head>
  13. <%
  14. request.setCharacterEncoding("GBK");   //设置编码方式为GBK
  15. AdminClass aClass = new AdminClass();
  16. News News1 = new News();
  17. Function Fun = new Function();
  18. String [][] sBig = aClass.GetAllClass(true,false,null);
  19. String [][] sSmall = aClass.GetAllClass(false,false,null);
  20. String [][] sSpecial = aClass.GetAllClass(true,true,null);
  21. String AdminName = (String)session.getAttribute("AdminName"); 
  22. String Action = request.getParameter("Action");
  23. if (Action!=null && Action.equals("Add"))
  24. {
  25. String IP = request.getRemoteAddr(); //得到客户端Ip地址
  26. String [] s = new String[15];
  27. s[0] = request.getParameter("NewsTitle");
  28. s[1] = request.getParameter("NewsContent");
  29. s[2] = request.getParameter("NewsKey");
  30. s[3] = request.getParameter("NewsAuthor");
  31. s[4] = request.getParameter("NewsFrom");
  32. s[5] = (new java.util.Date()).toLocaleString();
  33. s[6] = request.getParameter("NewsPicture");
  34. s[7] = request.getParameter("BigClassID");
  35. s[8] = request.getParameter("SClassID");
  36. s[9] = request.getParameter("IsHead");
  37. s[10] = request.getParameter("HeadPicture");
  38. s[11] = request.getParameter("IsImg");
  39. s[12] = request.getParameter("IsHot");
  40. s[13] = request.getParameter("SpecialID");
  41. s[14] = request.getParameter("NewsInfo");
  42. String sNews = News1.AddNews(s,AdminName,IP);
  43. if (sNews.equals("Yes"))
  44. {
  45. out.print("<script>alert('添加新闻成功!');location.href='ListNews.jsp';</script>");
  46. return;
  47. }
  48. else 
  49. {
  50. out.print(Fun.OutError(sNews));
  51. return;
  52. }
  53. }
  54. %>
  55. <script language = "JavaScript">
  56. var iCount;
  57. subcat = new Array();
  58. <%
  59. if(sSmall!=null)
  60. {
  61. int iCount = 0;
  62. for(iCount=0;iCount<sSmall.length;iCount++)
  63. {
  64. %>
  65. subcat[<%=iCount%>] = new Array("<%=sSmall[iCount][0]%>","<%=sSmall[iCount][1]%>","<%=sSmall[iCount][2]%>");
  66. <% } %>
  67. iCount=<%=iCount%>;
  68. <% } %>
  69. </script>
  70. <body>
  71. <br><br>
  72. <form name="AddNews" method="POST" action="AddNews.jsp" onSubmit="return CheckNews();">
  73. <table width="90%" border="1" align=center cellpadding="1" cellspacing="1">
  74.   <tr background="images/bg.gif">
  75.     <td height="27" colspan="3" background="images/bg.gif">&nbsp;&nbsp;<b class="title">添加新闻 <span class="info1">&nbsp;&nbsp;操作管理员 [<%=AdminName%>]</span></b></td>
  76.   </tr>
  77.   <tr class="chinese">
  78.     <td width="130" height="25" align="right"><div align="right">所属大类:</div></td>
  79.     <td height="25" colspan="2">
  80. <select name="BigClassID" onChange="ChangeLocation(document.AddNews.BigClassID.options[document.AddNews.BigClassID.selectedIndex].value)" size="1" class="chinese">
  81. <%  
  82. if (sBig==null)
  83. {
  84. out.println("<option value="" selected>暂无大类</option>");
  85. }
  86. else
  87. {
  88. out.println("<option value="" selected>请选择大类</option>");
  89. for(int i=0;i<sBig.length;i++)
  90. {
  91. out.print("<option value="" + sBig[i][0] + """);
  92. //if(i==0) out.print(" selected"); 
  93. out.println(">" + sBig[i][1] + "</option>");
  94. }
  95. }
  96.  %>
  97. </select>&nbsp;
  98. <select name="SClassID" size="1" class="chinese" id="SClassID">
  99.   <%  
  100. if(sBig!=null)
  101. {
  102. String [][] sSmall1 = aClass.GetAllClass(false,false,sBig[0][0]);
  103. if (sSmall1==null)
  104. {
  105. out.println("<option value="" selected>暂无小类</option>");
  106. }
  107. else
  108. {
  109. out.println("<option value="" selected>请选择小类</option>");
  110. for(int i=0;i<sSmall1.length;i++)
  111. {
  112. out.print("<option value="" + sSmall1[i][0] + """);
  113. //if(i==0) out.print(" selected"); 
  114. out.println(">" + sSmall1[i][1] + "</option>");
  115. }
  116. }
  117. }
  118. else out.println("<option value="" selected>暂无小类</option>");
  119.  %>
  120. </select><span class="info1">&nbsp;*请选择新闻的类别</span></td>
  121.   </tr>
  122.   <tr class="chinese">
  123.     <td width="130" height="25" align="right">所属专题:</td>
  124.     <td height="25" colspan="2">
  125. <select name="SpecialID" size="1" class="chinese" id="SpecialID" onChange="ChangeLocation(document.AddNews.BigClassID.options[document.AddNews.BigClassID.selectedIndex].value)">
  126.       <option selected value="">不属于任何专题</option>
  127.       <%    if (sSpecial==null)
  128. {
  129. out.println("<option value="" selected>暂无专题</option>");
  130. }
  131. else
  132. {
  133. for(int i=0;i<sSpecial.length;i++)
  134. {
  135. out.println("<option value="" + sSpecial[i][0] + "">" + sSpecial[i][1] + "</option>");
  136. }
  137. }
  138.  %>
  139.         </select></td>
  140.   </tr>
  141.   <tr class="chinese">
  142.     <td width="130" height="25" align="right">新闻标题:</td>
  143.     <td height="25" colspan="2"><input name="NewsTitle" type="text" class="chinese" id="NewsTitle" size="40" maxlength="60"></td>
  144.   </tr>
  145.   <tr class="chinese">
  146.     <td width="130" height="25" align="right">发布人:</td>
  147.     <td height="25" colspan="2"><input name="NewsAuthor" type="text" class="chinese" id="NewsAuthor" size="40" maxlength="20"></td>
  148.   </tr>
  149.   <tr class="chinese">
  150.     <td width="130" height="25" align="right">新闻出处:</td>
  151.     <td height="25" colspan="2"><input name="NewsFrom" type="text" class="chinese" id="NewsFrom" size="40" maxlength="60"></td>
  152.   </tr>
  153.   <tr class="chinese">
  154.     <td width="130" height="25" align="right">新闻关键字:</td>
  155.     <td height="25" colspan="2"><input name="NewsKey" type="text" class="chinese" id="NewsKey" size="40" maxlength="30"></td>
  156.   </tr>
  157.   <tr class="chinese">
  158.     <td width="130" height="25" align="right">是否图片新闻:</td>
  159.     <td width="90" height="25"><label><input type="radio" name="IsImg" value="Yes" onClick="ShowPicture(true)">是</label>
  160.       <label><input name="IsImg" type="radio" value="No" checked onClick="ShowPicture(false)">否</label></td>
  161.  <td width="462" height="25">
  162.  <div id="p" style="display:none">&nbsp;<input name="NewsPicture" type="text" class="chinese" id="NewsPicture" size=25 maxlength="80" style="display:" value="">
  163.  <input name="UpImg" type="button" class="button" id="UpImg" onClick="getPicture()" value="上传新闻图片>>">&nbsp;<span class="info1">(130*80)</span></div></td>
  164. </tr>
  165.   <tr class="chinese">
  166.     <td width="130" height="25"><div align="right">是否头条新闻:</div></td>
  167.     <td width="90" height="25"><label><input type="radio" name="IsHead" value="Yes" onClick="ShowHeadPicture(true)">是</label>
  168.       <label><input name="IsHead" type="radio" value="No" checked onClick="ShowHeadPicture(false)">否</label></td>
  169.     <td height="25">
  170.  <div id="p1" style="display:none">&nbsp;<input name="HeadPicture" type="text" class="chinese" id="HeadPicture" size=25 maxlength="80" style="display:" value="">
  171.      <input name="UpImg" type="button" class="button" id="UpImg" onClick="getHeadPicture()" value="上传头条图片>>">&nbsp;<span class="info1">(250*140)</span></div>
  172. </td>
  173.     </tr>
  174.   <tr class="chinese">
  175.     <td width="130" height="25" align="right">是否滚动新闻:</td>
  176.     <td height="25" colspan="2"><label><input name="IsHot" type="radio" value="Yes">是</label>
  177.       <label><input name="IsHot" type="radio" value="No" checked>否</label></td>
  178.     </tr>
  179.   <tr class="chinese">
  180.     <td height="25" align="right">新闻摘要:</td>
  181.     <td height="25" colspan="2"><textarea name="NewsInfo" cols="40" rows="3" id="NewsInfo"></textarea> 
  182.       <span class="info1">*120字以内</span></td>
  183.   </tr>
  184.   <tr class="chinese">
  185.     <td width="130" height="25" align="right">新闻内容:</td>
  186.     <td height="25" colspan="2">&nbsp;</td>
  187.   </tr>
  188.   <tr>
  189.     <td height="25" colspan="3"><div align="center">
  190.       <textarea name="NewsContent" class="chinese" style="display:none"></textarea>
  191.       <iframe ID="DreamEditor" src="../eWebEditor.jsp?id=NewsContent&style=CoolBlue" frameborder="0" scrolling="no" width="620" height="350"></iframe>
  192.     </div></td>
  193.     </tr>
  194.   <tr>
  195.     <td colspan=3><p align="center"><br>
  196.       <input name="B1" type="button" class="button" value="返回>>" onClick="location.href='ListNews.jsp'">
  197.       <input name="Action" type="hidden" id="Action" value="Add">&nbsp;
  198.       <input name="B2" type="submit" class="button" id="B2" value="增加>>">
  199.       <br>
  200.       <br><br></p></td>
  201.   </tr>
  202. </table>
  203. <br>
  204. <br>
  205. </form>
  206. </body>
  207. </html>