📄 newsmodify.jsp
字号:
<%@ page contentType="text/html; charset=GB2312"
language="java"
import = "java.util.*, java.text.*,java.sql.*,MyBean.charsetConvert"
%>
<jsp:useBean id="dbc" scope="session" class="MyBean.dbcon" />
<%
String snewsid="";
if(session.getAttribute("snewsid")!=null)
snewsid=session.getAttribute("snewsid").toString();
String Title="";
String Content="";
String uptime="";
String newstypeid="0";
String newstype="";
String copyfrom="";
String newsid=request.getParameter("newsid");
ResultSet nrs=dbc.executeQuery(" select a.title,a.content,a.uptime,b.newstypeid,b.newstype,a.copyfrom "
+" from newsinfo a , typeinfo b "
+" where a.newstypeid=b.newstypeid and newsid="+newsid);
session.setAttribute("snewsid",newsid);
while(nrs.next())
{
Title=nrs.getString("Title");
Content=nrs.getString("Content");
uptime=nrs.getString("uptime");
newstypeid=nrs.getString("newstypeid");
newstype=nrs.getString("newstype");
copyfrom=nrs.getString("copyfrom");
}
nrs.close();
String menu="";
try
{
menu = request.getParameter("menu");
}
catch(Exception ex)
{
menu="update";
}
if (menu==null || menu =="")
{
menu="update";
}
if(menu.equals("add"))
{
//java.util.Date date = new java.util.Date();
//SimpleDateFormat adddate= new SimpleDateFormat("yyyy-MM-dd");
Title=request.getParameter("Title");
Content=request.getParameter("Content");
newstypeid=request.getParameter("TypeID");
copyfrom=request.getParameter("copyfrom");
String tmp="";
tmp +=" update newsinfo set ";
tmp +=" title='"+Title+"',";
tmp +=" Content='"+Content+"',";
tmp +=" newstypeid="+newstypeid+",";
tmp +=" copyfrom='"+copyfrom+"' ";
tmp +=" where newsid="+snewsid;
tmp=charsetConvert.parseChinese(tmp);
if(dbc.executeUpdate(tmp)>=0)
out.println("<script>alert('新闻修改成功!');location.href='newslist.jsp'</script>");
else
out.println("<script>alert('新闻修改失败!');location.href='newslist.jsp'</script>");
}
%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="Style.css" type="text/css" rel="stylesheet">
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
}
-->
</style>
<script language = "JavaScript">
function CheckForm()
{
if (editor.EditMode.checked==true)
document.myform.Content.value=editor.HtmlEdit.document.body.innerText;
else
document.myform.Content.value=editor.HtmlEdit.document.body.innerHTML;
if (document.myform.Title.value=="")
{
alert("新闻标题不能为空!");
document.myform.Title.focus();
return false;
}
if (document.myform.TypeID.value=="")
{
alert("新闻类型不能为空!");
document.myform.TypeID.focus();
return false;
}
if (document.myform.Content.value=="")
{
alert("信息内容不能为空!");
editor.HtmlEdit.focus();
return false;
}
return true;
}
function loadForm()
{
editor.HtmlEdit.document.body.innerHTML=document.myform.Content.value;
return true
}
</script>
</head>
<body onLoad="javascipt:setTimeout('loadForm()',100);">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" valign="top" background="images/11.gif">
<form name="myform" method="post" onSubmit="return CheckForm();">
<table width="100%" border="1" align="center" cellpadding="2" bordercolor="#C0C0C0" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" bgcolor="#EEEEEE">
<tr>
<td ><div align="center">新闻标题:</div></td>
<td ><input name="Title" type="text" size="30" value="<%=Title%>"></td>
</tr>
<tr>
<td ><div align="center">新闻类型:</div></td>
<td>
<select name="TypeID" id="TypeID">
<%
ResultSet rs=dbc.executeQuery("select * from typeinfo ");
while(rs.next())
{
out.println("<option value="+rs.getString("newstypeid")+">+"+rs.getString("newstype")+"</option>");
}
%>
</select> <div align="center"></div></td>
</tr>
<tr>
<td><div align="center">新闻来源:</div></td>
<td colspan="3"><input name="copyfrom" type="text" size="80" value="<%=copyfrom%>" >
<div align="center"></div></td>
</tr>
<tr>
<td valign="top"><div align="center"><br>
新闻内容:</div></td>
<td colspan="3"><textarea name="Content" style="display:none"><%=Content%></textarea>
<iframe ID="editor" src="../editor.jsp" frameborder=1 scrolling=no width="100%" height="405"></iframe>
</td></td>
</tr>
<tr>
<td colspan="4"><div align="center">
<input type="submit" name="Submit" value="提交" onClick="document.myform.action='newsmodify.jsp?menu=add'">
</div></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -