寻这个通用的分页模块在网页中显示无效的解决办法,在线恳求。。。。。。

jxyy601 2008-03-07 05:51:37
<%
'*******************************************************
'过程名:ShowPage
'显示“上一页,下一页”等信息
'参数:sDesURL -----链接地址,可以是一个文件名,也可以是一个有一些参数的URL
' nTotalNumber ----- 总数量
' nMaxPerPage ----- 每页数量
' nCurrentPage ----- 当前页
' bShowTotal ----- 是否显示总数量
' bShowCombo ----- 是否用下拉列表显示所有页面以提供跳转
' sUnit ----- 计数单位
'*******************************************************
sub ShowPage(sDesURL,nTotalNumber,nMaxPerPage,nCurrentPage,bShowTotal,bShowCombo,sUnit)
dim n,i,strTemp,strUrl
'计算页数
if nTotalNumber mod nMaxPerPage=0 then
n= nTotalNumber \ nMaxPerPage
else
n= nTotalNumber \ nMaxPerPage +1
end if
'判断当前页(nCurrentPage)
if nCurrentPage < 1 then
nCurrentPage = 1
elseif nCurrentPage > n then
nCurrentPage = n
end if

strTemp = "<table align='center' border='1' cellpadding='1' cellspacing='1'>"&_
"<form name='ShowPages' method='post' action='&sDesURL&'><tr><td>"

if bShowTotal =true then
strTemp= strTemp & "共收录<b>" &nTotalNumber& "</b>"& sUnit &"信息  "
end if
'根据输入的sDesURL向它加入"?"或者"&"
strUrl=PasteURL(sDesURL)
if nCurrentPage < 2 then
strTemp=strTemp & "首页 上一页 "
else
strTemp=strTemp & "<a href='"&strUrl&"page=1'>首页</a> "
strTemp=strTemp & "<a href='"&strUrl&"page="&(nCurrentPage-1)&"'>上一页</a> "
end if

if n-nCurrentPage<1 then
strTemp=strTemp & "下一页 页尾"
else
strTemp=strTemp & "<a href='"&strUrl&"page="&(nCurrentPage+1)&"'>下一页</a> "
strTemp=strTemp & "<a href='"&strUrl&"page=" & n & "'>尾页</a> "
end if

strTemp=strTemp & " 页次:<strong><font color=red>"& nCurrentPage &"</font>/"& n &"</strong>页"
strTemp=strTemp & " <b>"& nMaxPerPage &"</b>"&sUnit&"/页"

strTemp= strTemp& "</td></tr></form></table>"
response.Write(strTemp)
end sub

'*******************************************************************
'函数名:PasteURL
'作 用:向地址中加入"?"或"&"
'参 数:strUrl -----网址
'返回值:加入了"?"或"&"的网址
'*******************************************************************
function PasteURL(strUrl)
if strUrl="" then
PasteURL=""
exit function
end if

'如果传入的URL末尾不是"?"有两种情况:
'1.无"?",此时需要加入一个"?"
'2.有"?",再判断有无"&"
if InStr(strUrl,"?")< len(strUrl) then
if Instr(strUrl,"?")>1 then
if Instr(strUrl,"&")<len(strUrl) then
PasteURL=strUrl & "&"
else
PasteURL=strUrl
end if
else
PasteURL=strUrl & "?"
end if
else
PasteURL=strUrl
end if
end function
%>

  这段代码摘自一ASP书上,上述该模块在使用时用include包含进去,不做任何修改即可使用ShowPage函数实现分页功能。小弟将些保存在a.asp中,在b.asp中包含进来使用时<% Call ShowPage("b.asp",3,1,1,true,0,"条") %> 调用,却无法预计效果,改成<% Call ShowPage(Request.ServerVariables("SCRIPT_NAME"),rs_ground.RecordCount,2,Request("Page"),true,0,"条")%> 结果。。
  在些诚请名位仁兄,仁姐,高手们能指点一二,不胜感激!~~
...全文
28 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧