?? fav_edit.jsp
字號:
<%@ page language="java" contentType="text/html; charset=GBK" pageEncoding="GB18030" import="java.sql.*,java.util.*,java.io.*"%>
<%@ include file="config.ini"%>
<%@ include file="conn.jsp"%>
<%@ include file="readlogin.jsp"%>
<%
String id=request.getParameter("id");
if(id==null)
{
out.print("<script>");
out.print("alert('id錯誤');");
out.print("location.href='fav.jsp';");
out.print("</script>");
}
%>
<%
String action=request.getParameter("action");
if(action==null) {action="";}
if(action.equals("save"))
{
String title=codeToString(request.getParameter("title"));
String urlstr=codeToString(request.getParameter("urlstr"));
String sort=codeToString(request.getParameter("sort"));
try
{
sqlstr="update [fav] set [sort]='"+sort+"',[title]='"+title+"',[urlstr]='"+urlstr+"' where id="+id;
iCanDb.doUpdate(sqlstr);
out.print("<script>");
out.print("alert('修改成功!');");
out.print("location.href='fav.jsp';");
out.print("</script>");
}
catch(Exception e)
{
out.print("<script>");
out.print("alert('數據庫錯誤!');");
out.print("location.href='fav.jsp';");
out.print("</script>");
}
}
try
{
sqlstr="select * from fav where id="+id;
rs=iCanDb.doSelect(sqlstr);
if(rs.next())
{
String sort=rs.getString("sort");
String title=rs.getString("title");
String urlstr=rs.getString("urlstr");
%>
<html>
<head>
<%@ include file="head.jsp"%>
</head>
<script language="javascript">
function on_submit()
{//驗證數據的合法性
if (form1.title.value == "")
{
alert("標題不能為空");
form1.title.focus();
return false;
}
if (form1.urlstr.value == "")
{
alert("網址不能為空");
form1.urlstr.focus();
return false;
}
if (form1.sort.value == "")
{
alert("分類不能為空");
form1.sort.focus();
return false;
}
}
</script>
<body>
<center>
<table border="0" width="768" id="table1" cellspacing="0" cellpadding="0">
<tr>
<%@ include file="top.jsp"%>
</tr>
<tr>
<td width="90" valign="top">
<%@ include file="menu.jsp"%> </td>
<td width="588" valign="top">
<table border="0" width="100%" id="table3" cellspacing="0" cellpadding="0">
<tr>
<td>
<table border="1" width="100%" id="table4" bordercolorlight="#0A9EE4" cellspacing="0" cellpadding="5" bordercolordark="#0A9EE4" height=300>
<tr>
<td valign="top">
<table border="0" width="100%" id="table5" cellspacing="0" cellpadding="0">
<tr>
<td>
<table border="0" width="100%" id="table6" cellspacing="0" cellpadding="0">
<tr>
<td valign="bottom" width="50%">
</td>
<td width="50%">
<img src="images/n-fav.jpg" align="right" width="230" height="70"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><hr noshade color="#0A9EE4" size="1"></td>
</tr>
<tr>
<td>
<form method="POST" action="fav_edit.jsp?action=save&id=<%=id%>" target=_top name="form1" onsubmit="return on_submit()">
<table border="0" width="574" id="table7" cellspacing="0" cellpadding="5">
<tr>
<td width="116" height="40">
<p align="right">
<span style="font-size: 9pt">
收藏標題:</span></td>
<td width="438" height="40">
<span style="font-size: 9pt">
<input type="text" name="title" size="29" style="border: 1px solid #0A9EE4" value="<%=title%>"></span></td>
</tr>
<tr>
<td width="116" height="40">
<p align="right">
<span style="font-size: 9pt">分類:</span></td>
<td width="438" height="40">
<span style="font-size: 9pt"><select size="1" name="sort" style="border: 1px solid #0A9EE4">
<option selected value="網站" <%if(sort.trim().equals("網站")) {out.print("selected");}%>>網站
</option>
<option value="圖片" <%if(sort.trim().equals("網站")) {out.print("selected");}%>>網站</option>
<option value="音樂" <%if(sort.trim().equals("音樂")) {out.print("selected");}%>>音樂</option>
<option value="視頻" <%if(sort.trim().equals("視頻")) {out.print("selected");}%>>視頻</option>
<option value="Flash" <%if(sort.trim().equals("Flash")) {out.print("selected");}%>>Flash</option>
<option value="其他" <%if(sort.trim().equals("其他")) {out.print("selected");}%>>其他</option>
</select></span></td>
</tr>
<tr>
<td width="116" height="40">
<p align="right">
<span style="font-size: 9pt">URL:</span></td>
<td width="438" height="40">
<span style="font-size: 9pt">
<input type="text" name="urlstr" size="49" style="border: 1px solid #0A9EE4" value="<%=urlstr%>"></span></td>
</tr>
<tr>
<td width="116"> </td>
<td width="438"> </td>
</tr>
<tr>
<td width="574" colspan="2">
<p align="center"><input type="submit" value="提交" name="B1" style="border: 1px solid #156FC7">
<input type="button" value="返回" name="B2" style="border: 1px solid #156FC7" onclick="javascript:location.href='fav.jsp';"></td>
</tr>
</table></form>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td width="90"> </td>
</tr>
<tr>
<td width="90" valign="top">
</td>
<td width="588" valign="top">
<%@ include file="copyright.jsp"%>
</td>
<td width="90"> </td>
</tr>
</table>
<p>
</center>
</p>
</body>
</html>
<%
}
else
{
out.print("<script>");
out.print("alert('id錯誤!');");
out.print("location.href='fav.jsp';");
out.print("</script>");
}
}
catch(Exception e)
{
out.print("<script>");
out.print("alert('數據庫錯誤!');");
out.print("location.href='fav.jsp';");
out.print("</script>");
}
%>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -