模仿PHP写的ASP分页函数
来源:CSDN 时间:2008-04-13 06:11:00
分页程序sub show_page
参数说明:
total_records 总记录数
everypage_records 每页显示条数
current_page 当前页数
url 要传递的url,这里可以含有要传递的变量,比如 "list.asp?" 或者"list.asp?keyword=key&"
程序调用比较简单,不过还是比PHP的麻烦,继续努力中
<%
sub show_page(total_records,everypage_records,current_page,url) if IsNumeric (total_records) then
total_records=Int(total_records)
else
total_records=0
end if
if IsNumeric (everypage_records) then
everypage_records=Int(everypage_records)
if everypage_records<=0 then
everypage_records=10
end if
else
everypage_records=10
end if
if IsNumeric (current_page) then
current_page=Int(current_page)
else
current_page=1
end if
'取总页数,即最后一页
if total_records mod everypage_records=0 then
last_page=Int(total_records/everypage_records)
else
last_page=Int(total_records/everypage_records)+1
end if
'判断 current_page 是否符合标准,并附值给page
if current_page>=last_page then
page=last_page
elseif current_page<=1 then
page=1
else
page=current_page
end if
'上一页
if page<=0 then
prepg=0
else
prepg=page-1
end if
'下一页
if page=last_page then
nextpg=0
else
nextpg=page+1
end if
'本页开始记录
firstcount=prepg*everypage_records
'本页结束记录
if nextpg>=1 then
lastcount=(nextpg-1)*everypage_records
else
lastcount=total_records
end if
'开始分页导航条代码
pagenav=""
pagenav1=""
pagenav=pagenav&"显示第<b>"&firstcount&"-"&lastcount&"</b>条记录 共<b>"&total_records&"</b> 条记录"
pagenav1=pagenav1&"显示第<b>"&firstcount&"-"&lastcount&"</b>条记录 共<b>"&total_records&"</b> 条记录"
if last_page>1 then
'当有前后页时
pagenav=pagenav&" <a href='"&url&"page=1'>首页</a> "
pagenav1=pagenav1&" <a href='"&url&"page=1'>首页</a> "
if prepg>=1 then
pagenav=pagenav&" <a href='"&url&"page="&prepg&"'>前页</a> "
pagenav1=pagenav1&" <a href='"&url&"page="&prepg&"'>前页</a> "
else
pagenav=pagenav&" 前页 "
pagenav1=pagenav1&" 前页 "
end if
if nextpg>=1 then
pagenav=pagenav&" <a href='"&url&"page="&nextpg&"'>后页</a> "
pagenav1=pagenav1&" <a href='"&url&"page="&nextpg&"'>后页</a> "
else
pagenav=pagenav&" 后页 "
pagenav1=pagenav1&" 后页 "
end if
pagenav=pagenav&" <a href='"&url&"page="&last_page&"'>尾页</a> "
pagenav1=pagenav1&" <a href='"&url&"page="&last_page&"'>尾页</a> "
pagenav=pagenav&"到第<input type=text name=text100 id=text100 value="&page&" size=3>页<input type=button name=button100 value=go onclick='window.location="""&url&"page=""+text100.value'>"
pagenav=pagenav&" 共 "&last_page&" 页"
pagenav1=pagenav1&"到第<input type=text name=text101 id=text101 value="&page&" size=3>页<input type=button name=button101 value=go onclick='window.location="""&url&"page=""+text101.value'>"
pagenav1=pagenav1&" 共 "&last_page&" 页"
end if
end sub
%>
标签:分页,函数,asp
0
投稿
猜你喜欢
SQL Server 2000 占内存居高不下可能的原因及其解决方法
2010-04-25 10:39:00
ASP把数字用逗号每3位隔开显示代码
2008-01-02 13:11:00
HTML 5 胜出:XHTML2 宣告夭折
2009-07-12 15:23:00
网站导航设计模式指南
2011-03-04 16:12:00
利用location.hash实现跨域iframe自适应高宽
2009-08-02 20:31:00
如何使用表单发送电子邮件?
2010-05-16 15:13:00
Frontpage轻松下载网页或站点
2007-10-22 13:14:00
长期使用中型Access数据库的一点经验
2007-12-21 13:23:00
Oracle 安装和卸载问题收集(集合篇)第1/6页
2009-07-02 12:20:00
position、z-index、top、right、bottom和left属性
2009-10-04 20:33:00
CSS的另类拼图___减少HTTP请求
2009-05-28 19:05:00
一个输入框提示列表效果
2008-03-09 18:53:00
博客使用标签是迟早的事
2008-10-31 12:55:00
数据库主键的故事
2008-05-31 07:50:00
不要犯WEB字体编辑的10种错误
2008-08-19 12:55:00
SQL触发器在保持数据库完整性中的实际应用
2009-10-23 14:34:00
在FLASH中调用ASP的方法
2009-03-09 18:32:00
从8个方面优化ASP代码
2007-09-16 18:01:00
用ASP建立一个简单的聊天室
2007-09-21 12:43:00
带你深入了解MySQL语句优化的基本原则
2008-11-27 17:00:00