函数
'====================================================================================== '*****参数说明***** 'totalpage总页数 'numperpage每页多少记录 'page当前页码 'pageurl指向URL 'pageindex页码序列数量 0 不显示页码序列 'attachinfo附加参数 如分类 搜索标记和词 等等 '*****Css样式说明***** 'PageDiv 最外层DIV 'a标签页码按钮 'CurrentPage当前页码按钮样式 'Disabled禁用按钮样式 '====================================================================================== Function pagination (totalpage,numperpage,page,pageurl,pageindex,attachinfo) PageLIstStr="" AttachInfoStr=attachinfo PageLIstStr="<div class=""PageDiv"">" if page>1 then PageLIstStr=PageLIstStr&"<a href=?page=1&"&AttachInfoStr&">FirstPage</a> " PageLIstStr=PageLIstStr&"<a href=?page="&(page-1)&AttachInfoStr&">PreviousPage</a> " else PageLIstStr=PageLIstStr&"<a class=""Disabled"">FirstPage</a> " PageLIstStr=PageLIstStr&"<a class=""Disabled"">PreviousPage</a> " end if '根据当前页码求FirstPage码和最后页码 if pageindex>0 then Shows=pageindex FirstPage=page-round(Shows/2) if FirstPage<1 then FirstPage=1 LastPage=FirstPage+(Shows-1) 'response.write "FirstPage="&FirstPage 'response.write "LastPage="&LastPage 'response.write "totalpage="&totalpage if totalpage-LastPage<0 then 'response.write "totalpage-LastPage="&totalpage-LastPage FirstPage=FirstPage+(totalpage-LastPage) end if if LastPage-FirstPage<(Shows-1) then FirstPage=FirstPage-LastPage-FirstPage end if 'response.write FirstPage if FirstPage<1 then FirstPage=1 if FirstPage>1 then PageLIstStr=PageLIstStr& "<a href=""?page=1&"&AttachInfoStr&"""> 1 </a> ... " else PageLIstStr=PageLIstStr& "<a class=""Disabled""> 1 </a> ... " end if for i=FirstPage to LastPage if i=page then PageLIstStr=PageLIstStr& "<a class=""CurrentPage"" href=""?page="&i&AttachInfoStr&"""> "&i&" </a> " else PageLIstStr=PageLIstStr& "<a href=""?page="&i&AttachInfoStr&"""> "&i&" </a> " end if if i>=totalpage then exit for next if LastPage<totalpage then PageLIstStr=PageLIstStr& "... <a href=""?page="&totalpage&AttachInfoStr&"""> "&totalpage&" </a> " else PageLIstStr=PageLIstStr& "... <a class=""Disabled""> "&totalpage&" </a> " end if end if if page <> totalpage then PageLIstStr=PageLIstStr&"<a href=""?page="&(page+1)&AttachInfoStr&""">NextPage</a> " PageLIstStr=PageLIstStr&"<a href=""?page="&totalpage&AttachInfoStr&""">LastPage</a> " else PageLIstStr=PageLIstStr&"<a class=""Disabled"">NextPage</a> " PageLIstStr=PageLIstStr&"<a class=""Disabled"">LastPage</a> " end if PageLIstStr=PageLIstStr&"</div>" pagination=PageLIstStr End Function
attachinfo="&model=List&searchkey=关键词" response.write pagination (totalpage,numperpage,page,pageurl,pageindex,attachinfo)
.PageDiv { width: 100%; text-align: center; font-size: 14px; margin: 10px; } .PageDiv a { display: inline-block; background: #ff6600; padding: 5px 10px; color: #fff; text-decoration: none; border-radius: 2px; } .PageDiv a:hover { background: #0066cc; } .PageDiv .CurrentPage { background: #0066cc; } .PageDiv .Disabled { background: #A7A7A7; cursor:default; } .PageDiv .Disabled:hover { background: #A7A7A7; }