网络编程 
首页 > 网络编程 > 浏览文章

ShowPage 显示“上一页 下一页”等信息的封装代码

(编辑:jimmy 日期: 2025/2/27 浏览:3 次 )
'**************************************************
'函数名:ShowPage
'作  用:显示“上一页 下一页”等信息
'参  数:sFileName  ----链接地址
'       TotalNumber ----总数量
'       MaxPerPage  ----每页数量
'       ShowTotal   ----是否显示总数量
'       ShowAllPages ---是否用下拉列表显示所有页面以供跳转。有某些页面不能使用,否则会出现JS错误。
'       strUnit     ----计数单位
'返回值:“上一页 下一页”等信息的HTML代码
'**************************************************
function ShowPage(sFileName,TotalNumber,MaxPerPage,ShowTotal,ShowAllPages,strUnit)
    dim TotalPage,strTemp,strUrl,i

    if TotalNumber=0 or MaxPerPage=0 or isNull(MaxPerPage) then
        ShowPage=""
        exit function
    end if
    if totalnumber mod maxperpage=0 then
        TotalPage= totalnumber \ maxperpage
      Else
        TotalPage= totalnumber \ maxperpage+1
      end if
    if CurrentPage>TotalPage then CurrentPage=TotalPage

      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 CurrentPage>=TotalPage then
        strTemp=strTemp & "下一页 尾页"
      Else
        strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage+1) & "'>下一页</a>&nbsp;"
        strTemp=strTemp & "<a href='" & strUrl & "page=" & TotalPage & "'>尾页</a>"
      end if
       strTemp=strTemp & "&nbsp;页次:<strong><font color=red>" & CurrentPage & "</font>/" & TotalPage & "</strong>页 "
        strTemp=strTemp & "&nbsp;<b>" & maxperpage & "</b>" & strUnit & "/页"
    if ShowAllPages=True then
        strTemp=strTemp & "&nbsp;&nbsp;转到第<input type='text' name='page' size='3' maxlength='5' value='" & CurrentPage & "' onKeyPress=""if (event.keyCode==13) window.location='" & strUrl & "page=" & "'+this.value;""'>页"
         'strTemp  = strTemp &"&nbsp;<Input type=""button""  onClick=""window.location.href='" & strUrl & "page='+document.all.page.value;""  name=button1  value=GO >"
    end if
    strTemp=strTemp & "</td></tr></table>"
    ShowPage=strTemp
end function
上一篇:JoinChar 向地址中加入 ? 或 & 用于实现传参
下一篇:asp实现检查目录是否存在与建立目录的函数
一句话新闻
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。