A good pagination method, the way to delete data (with real and cancel windows), search keywords (including spaces) processing

Source: Internet
Author: User
Tags date prev
pagination | keywords | data <!--#include file= "connect.asp"-->
<%
Keyword=request ("Keyword")
Keyword=replace (Keyword, "", "")

page = request.querystring ("page")

Sql= "SELECT * from quiz paper information where quiz paper name like '% ' &keyword& '% '"
Rs.Open sql,conn,1,1

Dim page,maxperpage
maxperpage=2 ' number of records displayed per page
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= "" style= "width:390; Height:20 ">
<input type= "Submit" Name= "Sub" value= "Query" ></td></form>

<%
If not (rs.eof or err) then Rs.move (page-1) *maxperpage
Do, I < maxperpage and not rs.eof%>

<% =rs ("quiz name")%> <a href= "2.asp?mode=del&page=<% =page%>" > Delete </a><br>

<% n=n+1
If N>=maxperpage then Exit Do
Rs.movenext
Loop
%>

<div align= "Right" ><font color= #FFFFFF > Total <b><%=rs.recordCount%></b> Item <b><% =page%>/<%=rs.pagecount%></b> page </font>
<%if page>1 then%>
<input type= "button" Name= "Submit3" value= "Home" onclick= "Javascript:jumpto (1)" >
<input type= "Submit" Name= "SUBMIT4" value= "prev" onclick= "Javascript:jumpto (2)" >
<%else%>
<input type= "button" Name= "Submit3" value= "Home" disabled>
<input type= "Submit" Name= "SUBMIT4" value= "prev" disabled>
<%end if
If Rs.recordcount>page*maxperpage then%>
<input type= "Submit" Name= "Submit5" value= "next page" onclick= "Javascript:jumpto (3)" >
<input type= "Submit" Name= "Submit6" value= "Last" onclick= "Javascript:jumpto (4)" >
<%else%>
<input type= "Submit" Name= "Submit5" value= "next page" disabled>
<input type= "Submit" Name= "Submit6" value= "Last" disabled>
<%end if%>
</div>

<%
If request ("mode") = "Del" Then
Id=request ("id")
Page=request ("page")
%>
<script language= "JavaScript" >
<!--
Temp=window.confirm ("Can't Recover!") Are you sure you want to delete this record? ");
if (temp)
{
window.location.href= "del.asp?page=<% =page%>&date=<% =date ()%>"
}
Else
{
History.back ();
}
-->
</SCRIPT>
<%end if%>




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.