📄 news_typeadmin.asp
字号:
<!--#include file="admin.asp"-->
<%
if request("action")="add" then
chk_admin_login(1)
n_typename=Request.Form("n_typename")
If not conn.Execute("select * From [newstype] where typename='"&n_typename&"'").eof Then
Response.Write "<script language='javascript'>alert('对不起,"&n_typename&"已经存在,请后退重填!!');location.href='javascript:history.back()'</script>"
else
sql="select * from newstype"
rs.open sql,conn,1,3
rs.addnew
rs("typename")=n_typename
rs.update
rs.close
set rs=nothing
response.redirect "news_typeadmin.asp"
end if
end if
if request("action")="edit" then
chk_admin_login(2)
id=request.form("id")
new_name=request.Form("new_name")
sql="select * from newstype where id="&cint(id)
rs.open sql,conn,1,3
rs("typename")=new_name
rs.update
rs.close
response.write"<script>alert('修改成功!');location.href='news_typeadmin.asp'</script>"
end if
if request("action")="del" then
chk_admin_login(3)
sql="select * from newstype where id="&request.form("delid")
rs.open sql,conn,1,3
rs.delete
rs.close
set rs=nothing
response.redirect "news_typeadmin.asp"
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>管理类别</title>
<link rel=stylesheet href="../css/admin.css" type="text/css">
<script language="JavaScript">
function check_input()
{
if (form1.n_typename.value=="")
{ alert("请输入类别名称!");
form1.n_typename.focus();
return false;
}
return true;
}
function check_input2()
{
if (form2.id.value=="")
{ alert("请选择类别!");
form2.id.focus();
return false;
}
if (form2.new_name.value=="")
{ alert("请填写新的类别名称!");
form2.new_name.focus();
return false;
}
return true;
}
function check_input3()
{
if (form3.delid.value=="")
{ alert("请选择要删除的类别!");
form3.delid.focus();
return false;
}
if(confirm("确定要删除此类别吗?"))
return true;
else
return false;
}
</script>
</head>
<body>
<table width="70%" border="0" align="center" cellpadding="4" cellspacing="1" class="a2">
<tr class="a1">
<td height="25">添加新闻类别</td>
</tr>
<form name="form1" method="POST" action="?action=add" onSubmit="return check_input()">
<tr class="a4">
<td>输入名称:
<input name="n_typename" type="text" id="n_typename" size="20">
<input name="submit" type="submit" value=" 添 加 "> </td>
</tr>
</form>
</table>
<p></p>
<table width="70%" border="0" align="center" cellpadding="4" cellspacing="1" class="a2">
<form name="form2" method="post" action="?action=edit" onSubmit="return check_input2()">
<tr class="a1">
<td height="30" colspan="2">修改新闻类别</td>
</tr>
<tr class="a3">
<td width="72">选择类别:</td>
<td width="450">
<%
sql="select * from newstype"
rs.open sql,conn,1,1
%><select name="id" size="1">
<option selected value="">请选择</option>
<%do while not rs.eof%>
<option value=<%=rs("id")%>><%=rs("typename")%></option>
<%rs.movenext
loop
rs.close
set rs=nothing
%>
</select> </td>
</tr>
<tr class="a4">
<td>新的名称:</td>
<td><input name="new_name" type="text"></td>
</tr>
<tr class="a3">
<td> </td>
<td><input type="submit" name="Submit2" value=" 修 改 "></td>
</tr>
</form>
</table>
<p></p>
<table width="70%" border="0" align="center" cellpadding="4" cellspacing="1" class="a2">
<tr class="a1">
<td width="710" height="30">删除新闻类别</td>
</tr>
<tr>
<form name="form3" method="post" action="?action=del" onSubmit="return check_input3()">
<td class="a4"> <%
set rs2=server.createobject("ADODB.Recordset")
sql2="select * from newstype"
rs2.open sql2,conn,1,1
%>选择:<select name="delid" size="1">
<option selected value="">请选择</option>
<%do while not rs2.eof%>
<option value=<%=rs2("id")%>><%=rs2("typename")%></option>
<%rs2.movenext
loop
rs2.close
set rs2=nothing
%>
</select> <input type="submit" name="Submit3" value=" 删 除 ">
</td>
</form>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -