ASP通用分页样式函数代码

2018-09-06 11:13

阅读:557

  <%
******************************
函数:MultiPage(Numbers,Perpage,Curpage,Url_Add)
参数:Numbers,总记录数;Perpage,每页记录数;Curpage,当前页;Url_Add,当前页其它参数如?action=list&
作者:阿里西西
日期:2007/7/15
描述:ASP通用分页样式函数
示例:MultiPage(100,10,2,?action=list&)
******************************
FunctionMultiPage(Numbers,Perpage,Curpage,Url_Add)
CurPage=Int(Curpage)
DimURL
URL=Request.ServerVariables(Script_Name)&Url_Add
MultiPage=
DimPage,Offset,PageI
IfInt(Numbers)>Int(PerPage)Then
Page=10
Offset=2
DimPages,FromPage,ToPage
IfNumbersModCint(Perpage)=0Then
Pages=Int(Numbers/Perpage)
Else
Pages=Int(Numbers/Perpage)+1
EndIf
FromPage=Curpage-Offset
ToPage=Curpage+Page-Offset-1
IfPage>PagesThen
FromPage=1
ToPage=Pages
Else
IfFromPage<1Then
Topage=Curpage+1-FromPage
FromPage=1
If(ToPage-FromPage)<PageAnd(ToPage-FromPage)<PagesThenToPage=Page
ElseIFTopage>PagesThen
FromPage=Curpage-Pages+ToPage
ToPage=Pages
If(ToPage-FromPage)<PageAnd(ToPage-FromPage)<PagesThenFromPage=Pages-Page+1
EndIf
EndIf
MultiPage=<ahref=&Url&page=1><<</a>
ForPageI=FromPageTOToPage
IfPageI<>CurPageThen
MultiPage=MultiPage&<ahref=&Url&page=&PageI&>[&PageI&]</a>
Else
MultiPage=MultiPage&<b>[&PageI&]</b>
EndIf
Next
IfInt(Pages)>Int(Page)Then
MultiPage=MultiPage&...<ahref=&Url&page=&Pages&>[&pages&]>></a>
Else
MultiPage=MultiPage&<ahref=&Url&page=&Pages&>>></a>
EndIf
EndIf
EndFunction%>


评论


亲,登录后才可以留言!