ASP分页函数
来源:风之相随'S BLOG 发布时间:2009-07-06 12:41:00
<%
'***********************************************
'函数名: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 ----总数量
' maxperpage ----每页数量
' ShowTotal ----是否显示总数量
' ShowAllPages ---是否用下拉列表显示所有页面以供跳转。有某些页面不能使用,否则会出现JS错误。
' strUnit ----计数单位
'**************************************************
sub showpage(sfilename,totalnumber,maxperpage,ShowTotal,ShowAllPages,strUnit)
dim n, i,strTemp,strUrl
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
strTemp= "<table align='center'><tr><td><font size='2'>"
if ShowTotal=true then
strTemp=strTemp & "共 <b>" & totalnumber & "</b> " & strUnit & " "
end if
strUrl=JoinChar(sfilename)
if CurrentPage<2 then
strTemp=strTemp & "首页 上一页 "
else
strTemp=strTemp & "<a href='" & strUrl & "page=1'>首页</a> "
strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage-1) & "'>上一页</a> "
end if
if n-currentpage<1 then
strTemp=strTemp & "下一页 尾页"
else
strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage+1) & "'>下一页</a> "
strTemp=strTemp & "<a href='" & strUrl & "page=" & n & "'>尾页</a>"
end if
strTemp=strTemp & " 页次:<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
strTemp=strTemp & " <b>" & maxperpage & "</b>" & strUnit & "/页"
if ShowAllPages=True then
strTemp=strTemp & " 转到:<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 & "</font></td></tr></table>"
response.write strTemp
end sub
%>
列表页面的代码
<%
const MaxPerPage=15
dim totalPut,CurrentPage,TotalPages
dim strFileName
dim strEmplName
strEmplName = strReplace(request("emplName"))
strFileName="employeeList.asp?emplName="&strEmplName&""
if request("page")<>"" then
CurrentPage=cint(request("page"))
else
CurrentPage=1
end if
%>
<form name="form1" method="post" action="">
用户名:<input name="emplName" type="text" class="myinput" id="emplName">
<input name="Submit" type="submit" class="mybutton" value="提交">
</form>
<table width="100%" border="1" cellspacing="1" cellpadding="5" id="bgtable">
<tr>
<td colspan="6" align="center" id="bgtitle">员工列表</td>
</tr>
<tr>
<td width="13%" align="center" id="bgtitle">用户名</td>
<td width="13%" align="center" id="bgtitle">姓名</td>
<td width="20%" align="center" id="bgtitle">所属部门</td>
</tr>
<%
sql = "select * from admin_employee where flag <> 1"
if strEmplName = "" then
sql = sql
else
sql = sql&" and userName like '%"&strEmplName&"%'"
end if
rs.open sql,conn,1,1
if not(rs.bof and rs.eof) then
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage strFileName,totalput,MaxPerPage,true,true,""
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage strFileName,totalput,MaxPerPage,true,true,""
else
currentPage=1
showContent
showpage strFileName,totalput,MaxPerPage,true,true,""
end if
end if
rs.Close
sub showContent()
dim i
i=0
do while not rs.eof
%>
<tr>
<td align="center" id="bkbody"><%=rs("userName")%></td>
<td align="center" id="bkbody"><%=rs("realName")%></td>
<td align="center" id="bkbody"><%=rs("deptName")%></td>
</td>
</tr>
<%
i=i+1
if i>=MaxPerPage then exit do
rs.MoveNext
loop
end sub
else
%>
<tr>
<td colspan="6" align="center" id="bkbody">暂时还没有员工信息!</td>
</tr>
<%
end if
%>
</table>


猜你喜欢
- 启动服务发生1067错误:1.删除datadir 下的用户数据库文件 和 日志文件 (ib_logfile0,ib_logfile1)。2.
- python简单的学生信息管理系统-文件版,供大家参考,具体内容如下功能如下主函数部分增加学生信息修改学生信息删除学生信息查询学生显示所有学
- 1、局部变量name = "Yang Li"def change_name(name): print(&qu
- requests接口测试的介绍requests是一个很实用的Python HTTP客户端库,编写爬虫和测试服务器响应数据时经常会用到,Req
- 我们在日常开发中,我们经常会面对复杂的子系统,其中包含许多相互关联的类和接口。直接使用这些类和接口可能会导致代码的复杂性增加,使得系统难以维
- Object 类型的对象虽然有 toString 方法,但结果却是 [Object Object] 让人没法理解的字符。比如简单的对象:{n
- 前言因为项目需要,存储字段存储成了JSON格式,在项目中是将查询出来的值通过jackson转成相应的bean进行处理的,觉得不够简单方便。M
- 要实现div的任意拖动,我们不妨分析一下整个过程。 当鼠标点击div时,触发一个事件,让div的位置属性(left,top)随着鼠标位置变化
- 1.错误错误1:parsing time “xx”: xxx out of range错误2:par
- Python sorted() 函数sorted() 函数对所有可迭代的对象进行排序操作sorted 语法:sorted(iterable,
- 1.在官网下载MySQL5.7安装包:mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz。下载地址:htt
- 将Django与其他现有认证系统的用户名和密码或者认证方法进行整合是可以办到的。例如,你所在的公司也许已经安装了LDAP,并且为每一个员工都
- 为了吸引更多的用户,设计好一个分享海报还是很有必要的。而小程序要生成一个海报还是有点坑的,下面分享下我们打卡小程序的一些经验。分享海报的效果
- 与抓取预定义好的页面集合不同,抓取一个网站的所有内链会带来一个 挑战,即你不知道会获得什么。好在有几种基本的方法可以识别页面类型。通过URL
- 一.一维数组的转置描述一维数组的重塑就是将一行或一列的数组转换为多行多列的数组重塑之后的数组应于原有数组形状兼容(数组元素应该相等)用法和参
- 没什么实际用途,纯属消遣Quick Click<html><head><title>Quick_Clic
- python svm实现手写数字识别——直接可用最近在做个围棋识别的项目,需要识别下面的数字,如下图:我发现现在网上很多代码是良莠不齐,…真
- 什么是prototype:function定义的对象有一个prototype属性,prototype属性又指向了一个prototype对象,
- 一:什么是exe?exe是Windows环境中的文件扩展名之一,它是一个可执行文件,虽然扩展程序在一般情况下是隐藏的,但是我们可以通过取消选
- 上次谈到客户端和服务端的编码“陷阱”,其中对url编码只是提及带过,并没有做深入讨论,事实上由于浏览器环境的复杂和不一致性,我们也很容易掉进