一段通用的分页函数

'从动力3.51分离出来的,可以通用的哦,研究一下。。。 
'
**************************************************
'
函数名:JoinChar
'
作   用:向地址中加入 ? 或 &
'
参   数:strUrl   ----网址
'
返回值:加了 ? 或 & 的网址
'
**************************************************
function JoinChar(strUrl)
if strUrl="" then
   JoinChar
=""
   
exit function
end if
if InStr(strUrl,"?")<len(strUrl) then 
   
if InStr(strUrl,"?")>1 then
   
if InStr(strUrl,"&")<len(strUrl) then 
     JoinChar
=strUrl & "&"
   
else
     JoinChar
=strUrl
   
end if
   
else
   JoinChar
=strUrl & "?"
   
end if
else
   JoinChar
=strUrl
end if
end function

'**************************************************
'
过程名:showpage
'
作   用:显示“上一页 下一页”等信息
'
参   数:sfilename   ----链接地址
'
       totalnumber ----总数量
'
       records   ----每页数量
'
       ShowTotal   ----是否显示总数量
'
       ShowAllPages ---是否用下拉列表显示所有页面以供跳转。有某些页面不能使用,否则会出现JS错误。
'
       strUnit     ----计数单位
'
**************************************************
sub showpage(sfilename,totalnumber,records,ShowTotal,ShowAllPages,strUnit)
dim n, i,strTemp,strUrl
if totalnumber mod records=0 then
     n
= totalnumber  records
   
else
     n
= totalnumber  records+1
   
end if
   strTemp
= "<table align='center'><tr><td>"
if ShowTotal=true then 
   strTemp
=strTemp & "共 <b>" & totalnumber & "</b> " & strUnit & "&nbsp;&nbsp;"
end if
strUrl
=JoinChar(sfilename)
   
if CurrentPage<2 then
       strTemp
=strTemp & "首页 上一页&nbsp;"
   
else
       strTemp
=strTemp & "<a href='" & strUrl & "page=1'>首页</a>&nbsp;"
       strTemp
=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage-1& "'>上一页</a>&nbsp;"
   
end if

   
if n-currentpage<1 then
       strTemp
=strTemp & "下一页 尾页"
   
else
       strTemp
=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage+1& "'>下一页</a>&nbsp;"
       strTemp
=strTemp & "<a href='" & strUrl & "page=" & n & "'>尾页</a>"
   
end if
     strTemp
=strTemp & "&nbsp;页次:<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
     strTemp
=strTemp & "&nbsp;<b>" & records & "</b>" & strUnit & "/页"
if ShowAllPages=True then
   strTemp
=strTemp & "&nbsp;转到:<select name='page' size='1' onchange=""javascript:window.location='" & strUrl & "page=" & "'+this.options[this.selectedIndex].value;"">"   
     
for i = 1 to n   
       strTemp
=strTemp & "<option value='" & i & "'"
   
if cint(CurrentPage)=cint(i) then strTemp=strTemp & " selected "
   strTemp
=strTemp & ">第" & i & "页</option>"   
     
next
   strTemp
=strTemp & "</select>"
end if
strTemp
=strTemp & "</td></tr></table>"
response.write strTemp
end sub
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值