ASP通用分页样式函数代码
程序员文章站
2022-05-28 16:16:47
<% '****************************** '函数:multipage(numbers,perpage,curpage,url_add) '...
<%
'******************************
'函数: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%>
'******************************
'函数: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%>