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>
猜你喜欢
- 任何一个行业里,当有一头近乎垄断的大象盘踞着的时候,生活在大象身后的蚂蚁们既是悲哀又是幸运的。悲哀的是市场已近乎被大象垄断留给他们的空间已经
- 人的大脑通过双眼来辨别视觉图形获取信息。大脑根据储存的经验,将所看到的视觉图形建立起优先级。由此可见,一个良好的视觉设计可以帮助大脑迅速有效
- 标志是一种简单的工具,就象铁锤,简单实用。如果一种工具功能太多导致其效用减弱,那就让它保持简单。你并不需要一把有太多装饰的精美铁锤。对于象征
- 是的,我们知道:我们可以为border设置它的width,这个border的宽度可以是5px,可是10px,可以是20px,可以是随意数值。
- 根据国务院文件,5.19-5.21为全国哀悼日,在此期间,全国和各驻外机构下半旗志哀,停止公共娱乐活动,外交部和我国驻外使领馆设立吊唁簿。5
- 很多时候我们写的程序,会花上一分钟甚至几分钟时间。为了使软件使用者能够耐心的等待程序的执行,我们经常会希望有一个进度条来表示程序执行的状态。
- 一、怎么样取得最新版本的MySQL?要安装MySQL,首先要当然要取得它的最新版本,虽然大家都知道在FreeBSD的Packages中可以找
- asp如何用Jmail的发送电子邮件?asp源码见下:<% Set mail1
- 页面大小、窗口大小和滚动条位置这三个数值在不同的浏览器例如Firefox和IE中有着不同的实现。即使在同一种浏览器例如IE中,不同版本也有不
- 对于PHP的逐渐流行,我们有目共睹:无论是BLOG程序中的WordPress,还是CMS程序中的DEDECMS,还是BBS程序中的Discu
- 请问论坛的树状记录表是怎么展开的?如何做?论坛的这种展开技术一般采用两种方法实现,一种是采用递归的方法,优点是逻辑简单,编程简单,缺点是速度
- 可以查看mysql文件目录my.ini文件,可以找到类似于 datadir="D:/beeagle/Program Files/M
- msxml3.dll 错误 '80004005'未指定的错误/Project/lijiang_071017/include/
- 当你提交一个查询的时候,MySQL会分析它,看是否可以做一些优化使处理该查询的速度更快。这一部分将介绍查询优化器是如何工作的。如果你想知道M
- 当你碰到下面的asp错误提示时,说明你asp运行脚本超时了! Active Serv
- 不知道有多少人清楚的知道,在Oracle中,如果一个复合索引,假定索引(a,b,c)三个字段,删除了(包括unused)其中一个字段,Ora
- 代码如下:DECLARE @c INT DECLARE @c2 INT SELECT @c = COUNT(1) FROM dbo.Spli
- 简介如果你经常网上冲浪,这样参差不齐的多栏布局,是不是很眼熟啊?类似的布局,似乎一夜之间出现在国内外大大小小的网站上,比如 Pinteres
- ASP实现语音分时问候,其实asp实现这个功能很容易,时间判断一下,在某个时间段就调用某个的背景语音。下面是源代码:
- 在做DHTML时,我们在某些情况下要用setAttribute(attri, value)方法定义元素的attribute。同时与getAt