Several forms of pagination

Source: Internet
Author: User
Tags prev

1. Paging Effect: Home first 10 1 2 3 4 5 6 7 8 9 10 later 10 last

<%
Dim Ipagecount,i,pagestart,pageend
Ipagecount = 30 ' Suppose there are 30 pages
If Request ("display") = "" Then
Curpage=1
Else
Curpage=cint (Request ("display")
End If
' Pages starting from Pagestart
Pagestart = ((curpage-1)/10) *10+1
' Pages from Pageend end
Pageend = Pagestart + 9
' If you exceed the total number of records, Pageend equals the total number of records
If Pageend > ipagecount Then pageend = Ipagecount
Response.Write ("First" & Curpage & "/" & Ipagecount & "page")
If Pagestart > 1 Then Response.Write ("<a href=test.asp?display=" & pageStart-10 & "><<</a>& amp;nbsp; ")
For i = Pagestart to Pageend
Response.Write ("<a href="? display= "& I &" ' > First "& I &" page </a> ")
Next
If Pageend < Ipagecount Then Response.Write ("<a href=test.asp?display=" & Pagestart + ten & ">>>< /a> ")
%>

2. Pagination Effect: A total of X article first prev Next last

'***********************************************
' Procedure name: ShowPage
' Function: Show "previous page next page" and other information
' parameter: sfilename----link Address
' Total number of totalnumber----
' Maxperpage----number per page
' Showtotal----Show total quantity
' Showallpages---whether to use the Drop-down list to display all the pages for jump. Some pages are not available, otherwise a JS error will appear.
' Strunit----count unit
'***********************************************
Sub ShowPage (Sfilename,totalnumber,maxperpage,showtotal,showallpages,strunit)
Dim n, I,strtemp,strurl
If Totalnumber mod maxperpage=0 then
n= Totalnumber/maxperpage
Else
n= totalnumber/maxperpage+1
End If
strtemp= "<table align= ' center ' ><form name= ' showpages ' method= ' Post ' action= '" & sFileName & "' > <tr><td> "
If Showtotal=true Then
Strtemp=strtemp & "Total <b>" & Totalnumber & "</b>" & Strunit & "&nbsp;&nbsp;"
End If
Strurl=joinchar (sFileName)
If Currentpage<2 Then
Strtemp=strtemp & "First prev &nbsp;"
Else
Strtemp=strtemp & "<a href= '" & strURL & "Page=1 ' > Home </a>&nbsp;"
Strtemp=strtemp & "<a href= '" & strURL & "Page=" & (CurrentPage-1) & "' > Previous </a>&nbsp;"
End If
' Response.Write (strtemp)

If N-currentpage<1 Then
Strtemp=strtemp & "Next Page last"
Else
Strtemp=strtemp & "<a href= '" & strURL & "Page=" & (currentpage+1) & "' > Next page </a>&nbsp;"
Strtemp=strtemp & "<a href= '" & strURL & "Page=" & N & "' > Last </a>"
End If
' Response.Write (strtemp)
Strtemp=strtemp & "&nbsp; page: <strong><font color=red>" & currentpage & "</font>/" & N & "</strong> page"
Strtemp=strtemp & "&nbsp;<b>" & Maxperpage & "</b>" & strunit & "/page"
If Showallpages=true Then
Strtemp=strtemp & "&nbsp; goto: <select name= ' page ' size= ' 1 ' onchange= ' javascript:submit () ' > '
For i = 1 to n
Strtemp=strtemp & "<option value= '" & I & "'"
If CInt (currentpage) =cint (i) then Strtemp=strtemp & "selected"
Strtemp=strtemp & "> First" & I & "Page </option>"
Next
Strtemp=strtemp & "</select>"
End If
Strtemp=strtemp & "</td></tr></form></table>"
Response.Write strtemp
End Sub

'***********************************************
' Function name: Joinchar
' Function: Add to address? Or &
' Parameters: strURL----URL
' Return value: Added? or & 's Web site
'***********************************************
function Joinchar (strURL)
If Strurl= "" Then
Joinchar= ""
Exit function
End If
If InStr (strURL, "?") <len (strURL) Then
If InStr (strURL, "?") >1 Then
If InStr (strURL, "&") <len (strURL) Then
Joinchar=strurl & "&"
Else
Joinchar=strurl
End If
Else
Joinchar=strurl & "?"
End If
Else
Joinchar=strurl
End If
End Function

Call can be called as follows:

ShowPage Strfilename,totalput,maxperpage,true,false, "article"

strFileName: Connection File
Totalput: Total Records
Maxperpage: Display quantity per page

3. A more flexible way, you can set the paging display effect

' Paging list function
' URL Jump Address
' Querry? ' after the argument
' Separator Separator
' ListType Paging type
' Type: 0 "First Page | Previous Page | Next Page | Last Page "
' Type: 1 ' 1 | 2 | 3 | 4 | ..........| Next Page "
' Type: 2 ' first page | First 10 pages | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | After 10 pages | Last Page "
' Listlink the style used by the link

Sub PageList (Listtype,url,querry,separator,listlink)
If separator= "" Then separator= "|"
If listtype= "" then listtype= "0"
Select Case ListType
Case "0"
Response.Write "&currentpage&"/"&n&" page &nbsp;&nbsp;
Response.Write "Total" &totalrec& "message &nbsp;&nbsp;"
If CurrentPage <= 1 Then
Response.Write "first Page &nbsp;" &Separator& "&nbsp;"
Response.Write "Previous Page &nbsp;" &Separator& "&nbsp;"
Else
Response.Write "<a href=" "&url&"?page=1& "&querry&" "class=" "" &ListLink& "" > First page </a>&nbsp; " &Separator& "&nbsp;"
Response.Write "<a href=" "&url&" "Page=" &currentpage-1& "&" &querry& "" "Class=" "" &ListLink& "" > previous page </a>&nbsp; " &Separator& "&nbsp;"
End If
If currentpage = n Then
Response.Write "Next Page &nbsp;" &Separator& "&nbsp;"
Response.Write "last Page &nbsp;"
Else
Response.Write "<a href=" "&url&" "Page=" &currentpage+1& "&" &querry& "" "Class=" "" &ListLink& "" > next page </a>&nbsp; " &Separator& "&nbsp;"
Response.Write "<a href=" "&url&" page= "&n&" & "&querry&" "" class= "" "&listlink & "" > Last page </a>&nbsp; "
End If
Case "1"
If CurrentPage < n Then
Response.Write "<a href=" "&url&" "Page=" &currentpage+1& "&" &querry& "" "Class=" "" &ListLink& "" > next page </a>&nbsp; "
Else
Response.Write "Next Page &nbsp;"
End If
For I=1 to N
If CStr (i) =cstr (currentpage) Then
Response.Write "<b>" &i& "</b>" & "&nbsp;" &Separator& "&nbsp;"
Else
Response.Write "<a href=" "&url&" page= "&i&" & "&querry&" "" class= "" "&listlink & "" > "&i&" </a>&nbsp; " &Separator& "&nbsp;"
End If
Next

Case "2"
Pagemercout=10 ' Maximum number of pages that can be flipped each time
' Get the maximum number of records
If n mod pagemercout=0 then
Maxpagefiled=n/pagemercout
Else
Maxpagefiled=n/pagemercout+1
End If
' Determine the page number of the current page
If CurrentPage mod pagemercout =0 Then
Currpagefiled=currentpage/pagemercout
Else
Currpagefiled=currentpage/pagemercout+1
End If
' Get the maximum and minimum page numbers for the current page segment
Maxpageno=currpagefiled*pagemercout
minpageno= (CurrPageFiled-1) *pagemercout+1
' Output ' first page | First 10 pages | "
If Currentpage<=1 Then
Response.Write "first Page &nbsp;" &Separator& "&nbsp;"
Else
Response.Write "<a href=" "&url&"?page=1& "&querry&" "class=" "" &ListLink& "" > First page </a>&nbsp; " &Separator& "&nbsp;"
End If
If Currpagefiled<=1 Then
Response.Write "Top 10 pages &nbsp;" &Separator& "&nbsp;"
Else
Response.Write "<a href=" "&url&" "Page=" &MinPageNo-PageMerCout& "&" &querry& "" " Class= "" "&ListLink&" "" > First 10 pages </a>&nbsp; " &Separator& "&nbsp;"
End If
' Output current page segment
For I=minpageno to Maxpageno
If I<=n Then
If CStr (i) =cstr (currentpage) Then
Response.Write "<b>" &i& "</b>" & "&nbsp;" &Separator& "&nbsp;"
Else
Response.Write "<a href=" "&url&" page= "&i&" & "&querry&" "" > "&i&" </a >&nbsp; " &Separator& "&nbsp;"
End If
End If
Next
' Output ' after 10 pages | Last Page "
If Currpagefiled>=maxpagefiled Then
Response.Write "After 10 pages &nbsp;" &Separator& "&nbsp;"
Else
Response.Write "<a href=" "&url&" page= "&MaxPageNo+1&" & "&querry&" "" Class= "" "& listlink& "" "> 10 page </a>&nbsp;" &Separator& "&nbsp;"
End If
If Currentpage>=n Then
Response.Write "last Page &nbsp;"
Else
Response.Write "<a href=" "&url&" page= "&n&" & "&querry&" "" class= "" "&listlink & "" > Last page </a>&nbsp; "
End If
End Select
End Sub

4. A relatively simple

On Error Resume Next
' Paging program
function fy (scount,pgsize,pg,url)
' Scount Total Records
' Pgsize per surface record number
' PG Current Page
' URL to the address, after running this function will be followed by the "&page= page number"
Dim pgcount,i,j,mh,k
MH=CHR (34) ' Sorry, it's double quotes.


' CInt () will be rounded, so I have to add a K
k= (scount+pgsize-1)/pgsize
Pgcount=cint ((scount+pgsize-1)/pgsize)
If Pgcount>k then pgcount=pgcount-1

Response.Write "<a href=" +mh+url+ "&page=1" +mh+ ">[first page]</a>&nbsp;"
If CInt (PG) >cint (1) Then
Response.Write "<a href=" +mh+url+ "&page=" +cstr (pg-1) +mh+ ">[previous page]</a>&nbsp;"
End If
If CInt (PG) >5 then
I=cint (PG)-5
Else
I=1
End If

If CInt (pgcount) <cint (pg+5) Then
J=pgcount
Else
J=pg+5
End If


While CInt (i) <=cint (j)

If CInt (i) =cint (PG) Then
Response.Write CStr (i) + "&nbsp;"
Else
Response.Write "<a href=" +mh+url+ "&page=" +cstr (i) +mh+ ">" +cstr (i) + "</a>&nbsp;"
End If
I=i+1
Wend

If CInt (Pgcount) >cint (PG) Then
Response.Write "<a href=" +mh+url+ "&page=" +cstr (pg+1) +mh+ ">[next page]</a>&nbsp;"
End If

Response.Write "<a href=" +mh+cstr (URL) + "&page=" +cstr (pgcount) +mh+ ">[last page]</a>&nbsp;"

End Function

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.