ASP通用分页样式函数代码
时间:2021-07-01 10:21:17
帮助过:18人阅读
<%
'******************************
'函数:MultiPage(Numbers,Perpage,Curpage,Url_Add)
'参数:Numbers,总记录数;Perpage,每页记录数;Curpage,当前页;Url_Add,当前页其它参数如?action=list&
'作者:阿里西西
'日期:2007/7/15
'描述:ASP通用分页样式函数
'示例:MultiPage(100,10,2,"?action=list&")
'******************************
Function MultiPage(Numbers,Perpage,Curpage,Url_Add)
CurPage=Int(Curpage)
Dim URL
URL=Request.ServerVariables("Script_Name")&Url_Add
MultiPage=""
Dim Page,Offset,PageI
If Int(Numbers)>Int(PerPage) Then
Page=10
Offset=2
Dim Pages,FromPage,ToPage
If Numbers Mod Cint(Perpage)=0 Then
Pages=Int(Numbers/Perpage)
Else
Pages=Int(Numbers/Perpage)+1
End If
FromPage=Curpage-Offset
ToPage=Curpage+Page-Offset-1
If Page>Pages Then
FromPage=1
ToPage=Pages
Else
If FromPage<1 Then
Topage=Curpage+1-FromPage
FromPage=1
If (ToPage-FromPage)<Page And (ToPage-FromPage)<Pages Then ToPage=Page
ElseIF Topage>Pages Then
FromPage =Curpage-Pages +ToPage
ToPage=Pages
If (ToPage-FromPage)<Page And (ToPage-FromPage)<Pages Then FromPage=Pages-Page+1
End If
End If
MultiPage="<a href='"&Url&"page=1'><<</a> "
For PageI=FromPage TO ToPage
If PageI<>CurPage Then
MultiPage=MultiPage&"<a href='"&Url&"page="&PageI&"'>["&PageI&"]</a> "
Else
MultiPage=MultiPage&"<b>["&PageI&"]</b> "
End If
Next
If Int(Pages)>Int(Page) Then
MultiPage=MultiPage&" ... <a href='"&Url&"page="&Pages&"'> ["&pages&"] >></a>"
Else
MultiPage=MultiPage&"<a href='"&Url&"page="&Pages&"'>>></a>"
End If
End If
End Function%>