最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp分页函数[推荐]
时间:2022-07-02 23:18:12 编辑:袖梨 来源:一聚教程网
<%
sql=""
Set Rs=Server.CreateObject("Adodb.RecordSet")
Rs.open Sql,TXconn,1,1
If Rs.RecordCount Then
TopNum=10 '定义每页显示多少条
QName="Page" '定义接收页码的变量名
Page=Request.QueryString(QName)
If Page="" Then
Page=1
ElseIf Not IsNumeric(Page) Then
Page=1
Else
Page=Page+0
End if
MaxPage=Fix(Rs.RecordCount/TopNum)
If (Rs.RecordCount mod TopNum) Then MaxPage=MaxPage+1
If Page>MaxPage Then Page=MaxPage
Rs.PageSize=TopNum
Rs.AbsolutePage = Page
For i=1 to TopNum
If Rs.bof or Rs.eof Then Exit For
Response.write(i&"
")
Rs.MoveNext
Next
Else
Response.write("no data")
End If
%>
<%=TXPage(Rs.RecordCount,TopNum,2,0,0,0,QName)%>
<% Title=""前"&PageNum*2&"页"">"&strBefore&" href="""&Url&QName&"="&Page-1&""" Title=""上一页"">"&strPrev&" 后"&PageNum*2&"页"">"&strAfter&" style=""overflow:visible;ime-mode:disabled;"" onkeydown=""javascript:if ('.8.13.37.39.46.48.49.50.51.52.53.54.55.56.57.96.97.98.99.100.101.102.103.104.105.'.indexOf('.'+event.keyCode+'.')>=0){if (event.keyCode==13){window.location.href='"&Url&QName&"='+value;}}else{return false;}"">"
Function TXPage(Totals,PerNums,PageNum,Info,List,Input,QName)
'分页函数(所有数量,每页显示记录数,页码个数,页码统计信息,下拉列表,输入框,页码变量名[为空则为Page])
Dim strBegin,strBefore,strPrev,strNext,strAfter,strEnd,BeginNum,EndNum,Page,Pages,Url
strBegin="9" '定义第一页按钮显示样式
strBefore="7" '定义上几页按钮显示样式
strPrev="3" '定义前一页按钮显示样式
strNext="4" '定义下一页按钮显示样式
strAfter="8" '定义后几页按钮显示样式
strEnd=":" '定义最后一页按钮显示样式
PageNum=Fix(PageNum/2)
If QName="" Then QName="Page"
Page=Request.QueryString(QName)
Url="?"
Dim Query,str,i
Query=Split(Request.ServerVariables("QUERY_STRING"),"&")
For i=0 to Ubound(Query)
Str=Split(Query(i),"=")
If Lcase(Str(0))<>Lcase(QName) Then Url=Url&Str(0)&"="&Str(1)&"&"
Next
PerNums=PerNums+0
If Totals mod PerNums Then
Pages=Fix(Totals/PerNums)+1
Else
Pages=Fix(Totals/PerNums)
End If
If IsNumeric(Page) Then
Page=Page+0
If Page>Pages Then
Page=Pages
ElseIf Page<1 Then
Page=1
End If
Else
Page=1
End If
TXPage=""
BeginNum=Page-PageNum
EndNum=Page+PageNum
If BeginNum<1 Then BeginNum=1
If EndNum-BeginNum
If EndNum-BeginNum
If BeginNum>PageNum*2 and PageNum>1 Then TXPage=TXPage&"
If BeginNum>1 Then TXPage=""&strBegin&""&TXPage&"
For i=BeginNum to EndNum
If i=Page Then
TXPage=TXPage&"["&i&"]"
Else
TXPage=TXPage&"["&i&"]"
End If
Next
If EndNum
If EndNum
If EndNum
If Info Then TXPage=TXPage&" 页次:"&Page&"/"&Pages&"页 共"&Totals&"条 "&PerNums&"条/页"
If List Then
TXPage=TXPage&" "
End If
If Input Then TXPage=TXPage&"
End Function
%>相关文章