一种很好的分页方法,删除数据的方式(带确实和取消窗口),搜索关键字(含空格)的处理

发表于:2007-06-30来源:作者:点击数: 标签:
!-- #include file=connect.asp -- % Keyword=request(Keyword) Keyword=replace(Keyword, ,) page = Request.QueryString(page) sql =select * from 试卷信息 where 试卷名称 like @#%keyword%@# rs.open sql,conn,1,1 dim page,maxPerPage maxPerPage=2 @#
<!-- #include file="connect.asp" -->
<%
Keyword=request("Keyword")
Keyword=replace(Keyword," ","")

page = Request.QueryString("page")

sql="select * from 试卷信息 where 试卷名称 like @#%"&keyword&"%@#"
rs.open sql,conn,1,1

dim page,maxPerPage
maxPerPage=2 @#每页显示的记录数
rs.pagesize=MaxPerPage
if (page="" or isempty(page)) then page=1
thisUrl="2.asp?Keyword="&Keyword
session("adminOldUrl")=thisUrl&"&page="&page
%>

<script language="JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function jumpTo(i){
if(i==1){
this.document.location="<%=thisUrl%>";}
if(i==2){
this.document.location="<%=thisUrl%>&page=<%=page-1%>";}
if(i==3){
this.document.location="<%=thisUrl%>&page=<%=page+1%>";}
if(i==4){
this.document.location="<%=thisUrl%>&page=<%=rs.pageCount%>";}
}
// -->
</script>

<form method="post" action="2.asp">
<input type="text" name="keyword" size=57 value="" maxlength="50" style="width: 390; height: 20">&nbsp;&nbsp;
<input type="submit" name="Sub" value=" 查 询 "></td></form>

<%
if not (rs.eof or err) then rs.move (page-1)*maxPerPage
do while i < maxPerPage And not rs.eof %>

<% =rs("试卷名称")%> <a href="2.asp?mode=del&page=<% =page%>">删 除</a><br>

<% n=n+1
if n>=maxPerPage then exit do
rs.movenext
loop
%>

<div align="right"><font color=#FFFFFF>共<b><%=rs.recordCount%></b>项 第<b><%=page%>/<%=rs.pageCount%></b>页 </font>
<%if page>1 then%>
<input type="button" name="Submit3" value="首页" onClick="Javascript:jumpTo(1)">
<input type="submit" name="Submit4" value="上页" onClick="Javascript:jumpTo(2)">
<%else%>
<input type="button" name="Submit3" value="首页" disabled>
<input type="submit" name="Submit4" value="上页" disabled>
<%end if
if rs.recordCount>page*maxPerPage then%>
<input type="submit" name="Submit5" value="下页" onClick="Javascript:jumpTo(3)">
<input type="submit" name="Submit6" value="末页" onClick="Javascript:jumpTo(4)">
<%else%>
<input type="submit" name="Submit5" value="下页" disabled>
<input type="submit" name="Submit6" value="末页" disabled>
<%end if%>
</div>

<%
if request("mode")="del" then
id=request("id")
page=request("page")
%>
<script language="javascript">
<!--
temp=window.confirm("不能恢复!您确实要删除此记录?");
if (temp)
{
window.location.href="del.asp?page=<% =page%>&Date=<% =date()%>"
}
else
{
history.back();
}
//-->
</SCRIPT>
<%end if%>


原文转自:http://www.ltesting.net