asp程序(2009-05-02 12:10:19)
全选:
<script language=javascript>
<!--
function CheckAll(form){
for (var i=0;i<form.elements.length;i++){
var e = form.elements[i];
if (e.name != 'chkall') e.checked = form.chkall.checked;
}
}
-->
</script>
<form action=user1.asp method=post name=user>
<input type='checkbox' value='' name=num>
<input type='checkbox' value='' name=num>
<input type='checkbox' value='' name=num>
<input type='checkbox' name=chkall onclick='CheckAll(this.form)'>全选
<input type=hidden name=action value="del">
<input type=submit value="删除" onClick="{if(confirm('确认要删除选定的会员吗?')){this.document.user.submit();return true;}return false;}"></form>
</div>
批量删除
<div style=" clear:both">
<script language=javascript>
<!--
function CheckAll(form){
for (var i=0;i<form.elements.length;i++){
var e = form.elements[i];
if (e.name != 'chkall') e.checked = form.chkall.checked;
}
}
-->
</script>
<form action="" method="post" name="user">
<%
set rs=conn.execute("select * from guestbook order by xu desc")
%>
<%if not (rs.eof and rs.bof) then
do while not rs.eof%>
<input type='checkbox' value='<%=rs("id")%>' name="num">
<input name="guest" type="text" value="<%=rs("guest")%>" size="10" maxlength="10" />
<%rs.movenext
loop
end if
%>
<input type='checkbox' name=chkall onclick='CheckAll(this.form)'>全选
<input type="hidden" name="action" value="del">
<input type="submit" value="删除" onClick="{if(confirm('确认要删除选定的会员吗?')){this.document.user.submit();return true;}return false;}"></form>
<%
action=request.form("action")
if action="del" then
delnum=request("num")
if delnum="" or isnull(delnum) then
response.write "<script language='javascript'>"
response.write "alert('出错了,您什么也没有选择!');"
response.write "location.href='guesttest.asp';"
response.write "</script>"
response.end
end if
conn.execute("delete from guestbook where id in ("&delnum&")")
response.write "<script language='javascript'>"
response.write "alert('操作成功,选定的会员已被删除!');"
response.write "location.href='guesttest.asp';"
response.write "</script>"
response.end
conn.close
set conn=nothing
end if
%>
</div>
当前记录集不支持书签。这可能是提供程序或选定的游标类型的限制
可能是因为:set rs=conn.execute("select * from kuan_type where kuanid like '%"&aboutid&"%' order by id desc")
要改成:set rs=server.createobject("adodb.recordset")
sql="select * from kuan_type where kuanid like '%"&aboutid&"%' order by id desc"
rs.open sql,conn,1,1
分页跳转页
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>登录...</title>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<!--#include file="commonfile/conn.asp"-->
<!--#include file="commonfile/rik.asp"-->
<%'开始分页
Const MaxPerPage=5
dim totalPut
dim CurrentPage
dim TotalPages
dim j
dim sql
if Not isempty(request("page")) then
currentPage=Cint(request("page"))
else
currentPage=1
end if
set rs=server.createobject("adodb.recordset")
rs.open "select * from book order by id desc",conn,1,1
if err.number<>0 then
response.write "数据库中无数据"
end if
if rs.eof And rs.bof then
Response.Write "<p align='center' class='contents'> 您还没有添加新闻!</p>"
else
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage totalput,MaxPerPage,"0001.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"0001.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"0001.asp"
end if
end if
end if
sub showContent
dim i
i=0
%>
<%do while not rs.eof%>
<TABLE cellSpacing=1 cellPadding=0 align=center border=0 class="chuhuo" width="1000">
<form name="form" method="post" action="0001.asp?id=<%=rs("id")%>" onSubmit="return check();">
<TR onmouseover="this.style.background='#f0f9ff'" onmouseout="this.style.background='#fffff'">
<TD><%=rs("yiid")%></TD>
<TD><input name="dantime" type="text" value="<%=rs("dantime")%>" size="9" maxlength="20"></TD>
<td><input type="submit" name="Submit" value="修改" onClick="return edit();" style=" cursor: pointer;color:#FF0000; border:1px #999999 solid " /><input type="hidden" name="update" value="soedit" /> <a href="0001.asp?shit=del&id=<%=rs("id")%>" style="color:#ff0000" onClick="return cform();">删除</a></td>
</TR>
</form>
</TABLE>
<%i=i+1
if i>=MaxPerPage then Exit Do
rs.movenext
loop
rs.close
set rs=nothing%>
<%
End Sub
Function showpage(totalnumber,maxperpage,filename)
Dim n
If totalnumber Mod maxperpage=0 Then
n= totalnumber \ maxperpage
Else
n= totalnumber \ maxperpage+1
End If
Response.Write "<form method=Post action="&filename&">"
Response.Write "<p align='center' class='contents'> "
If CurrentPage<2 Then
Response.Write "<font class='contents'>首页上一页</font> "
Else
Response.Write "<a href="&filename&"?page=1 class='contents'>首页</a> "
Response.Write "<a href="&filename&"?page="&CurrentPage-1&" class='contents'>上一页</a> "
End If
If n-currentpage<1 Then
Response.Write "<font class='contents'>下一页尾页</font>"
Else
Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&" class='contents'>"
Response.Write "下一页</a> <a href="&filename&"?page="&n&" class='contents'>尾页</a>"
End If
Response.Write "<font class='contents'> 页次:</font><font class='contents'>"&CurrentPage&"</font><font class='contents'>/"&n&"页</font> "
Response.Write "<font class='contents'> 共有"&totalnumber&"条新闻 "
Response.Write "<font class='contents'>转到:</font><input type='text' name='page' size=2 maxlength=10 class="smallInput" value="¤tpage&">"
Response.Write " <input type='submit' class='contents' value='GO' name='cndok'></form>"
End Function
%>
<%
if request.form("update")="soedit" then
set rs2=server.createobject("adodb.recordset")
sql2="select * from book where id="&request.QueryString("id")
rs2.open sql2,conn,1,3
rs2("dantime")=request("dantime")
rs2.update
rs2.close
set rs2=nothing
response.write "<script language='javascript'>"
response.write "alert('修改成功...');"
response.write "location.href='0001.asp';"
response.write "</script>"
end if
%>
</body>