关于翻页代码的问题

stephen0403 2009-10-22 09:03:55
参考网上的源代码,搞了一个翻页的公共模块,用的图片按钮,原代码中当输入要翻页的页数,直接按回车就可以跳转到相应页面,因为和部分功能有冲突,就加了个转向的按钮,不知道应该如何实现功能,曾在论坛上提问获取input值,用winonload,结果载入页面就弹出空白的网页提示信息。麻烦各位帮帮看看。谢谢。



<%
Sub TurnPage(ByRef Rs_tmp,PageSize) //Rs_tmp 记录集 ; PageSize 每页显示的记录条数;
Dim TotalPage //总页数
Dim PageNo //当前显示的是第几页
Dim RecordCount //总记录条数
Rs_tmp.PageSize = PageSize
RecordCount = Rs_tmp.RecordCount
TotalPage = INT(RecordCount / PageSize * -1)*-1
PageNo = Request.QueryString ("PageNo")
//直接输入页数跳转,这里被我注释掉了;
//If Request.Form("PageNo")<>"" Then PageNo = Request.Form("PageNo")
//如果没有选择第几页,则默认显示第一页;
If PageNo = "" then PageNo = 1
If RecordCount <> 0 then
Rs_tmp.AbsolutePage = PageNo
End If

//获取当前文件名,使得每次翻页都在当前页面进行;
Dim fileName,postion
fileName = Request.ServerVariables("script_name")
postion = InstrRev(fileName,"/")+1
//取得当前的文件名称,使翻页的链接指向当前文件;
fileName = Mid(fileName,postion)
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="STYLE4">  共有 <%=RecordCount%>条记录,当前第 <%=PageNo%>/<%=TotalPage%>页</td>
<td><table border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="40">
<%
If RecordCount = 0 or TotalPage = 1 Then
Else
%>
<a href="<%=fileName%>?PageNo=1"><img src="../images/first.gif" width="37" height="15" border="0" /></a></td>
<td width="45">
<%If PageNo - 1 = 0 Then
Else
%>
<a href="<%=fileName%>?PageNo=<%=PageNo-1%>"><img src="../images/pageup.gif" width="43" height="15" border="0" /></a></td>
<td width="45">
<%
End If
If PageNo+1 > TotalPage Then
Else
%>
<a href="<%=fileName%>?PageNo=<%=PageNo+1%>"><img src="../images/next.gif" width="43" height="15" border="0" /></a></td>
<td width="40">
<%End If%>
<a href="<%=fileName%>?PageNo=<%=TotalPage%>"><img src="../images/last.gif" width="37" height="15" border="0" /></a></td>
<%End If%>
<td width="120"><div align="center"><span class="STYLE1">转到第
<%
If TotalPage = 1 Then
%>
<input type=text name=PageNo size=3 readonly disabled style="background:#d3d3d3">
<%Else%>
<input name=PageNo type="text" size="4" style="height:12px; width:20px; border:1px solid #999999;" title=请输入页号,然后回车>//在这里输入页面数字点击下面这个超链图片跳转
<%End If%>页</span><a href="<%=fileName%>?PageNo=<%=PageNo%>"><img src="../images/go.gif" width="37" height="15" border="0" /></a></div></td>

</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<%End Sub%>

...全文
57 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
number123456 2009-10-22
  • 打赏
  • 举报
回复
<%
Sub TurnPage(ByRef Rs_tmp,PageSize) //Rs_tmp 记录集 ; PageSize 每页显示的记录条数;
Dim TotalPage //总页数
Dim PageNo //当前显示的是第几页
Dim RecordCount //总记录条数
Rs_tmp.PageSize = PageSize
RecordCount = Rs_tmp.RecordCount
TotalPage = INT(RecordCount / PageSize * -1)*-1
PageNo = Request.QueryString ("PageNo")
//直接输入页数跳转,这里被我注释掉了;
//If Request.Form("PageNo")<>"" Then PageNo = Request.Form("PageNo")
//如果没有选择第几页,则默认显示第一页;
If PageNo = "" then PageNo = 1
If RecordCount <> 0 then
Rs_tmp.AbsolutePage = PageNo
End If

//获取当前文件名,使得每次翻页都在当前页面进行;
Dim fileName,postion
fileName = Request.ServerVariables("script_name")
postion = InstrRev(fileName,"/")+1
//取得当前的文件名称,使翻页的链接指向当前文件;
fileName = Mid(fileName,postion)
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="STYLE4">  共有 <%=RecordCount%>条记录,当前第 <%=PageNo%>/<%=TotalPage%>页</td>
<td><table border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="40">
<%
If RecordCount = 0 or TotalPage = 1 Then
Else
%>
<a href="<%=fileName%>?PageNo=1"><img src="../images/first.gif" width="37" height="15" border="0" /></a></td>
<td width="45">
<%If PageNo - 1 = 0 Then
Else
%>
<a href="<%=fileName%>?PageNo=<%=PageNo-1%>"><img src="../images/pageup.gif" width="43" height="15" border="0" /></a></td>
<td width="45">
<%
End If
If PageNo+1 > TotalPage Then
Else
%>
<a href="<%=fileName%>?PageNo=<%=PageNo+1%>"><img src="../images/next.gif" width="43" height="15" border="0" /></a></td>
<td width="40">
<%End If%>
<a href="<%=fileName%>?PageNo=<%=TotalPage%>"><img src="../images/last.gif" width="37" height="15" border="0" /></a></td>
<%End If%>
<td width="120"><form id="form1" name="form1" method="get" action="<%=fileName%>">
<div align="center">
<span class="STYLE1">转到第
<%
If TotalPage = 1 Then
%>
<input type=text name=PageNo size=3 readonly disabled style="background:#d3d3d3">
<%Else%>
<input name=PageNo type="text" size="4" style="height:12px; width:20px; border:1px solid #999999;" title=请输入页号,然后回车>//在这里输入页面数字点击下面这个超链图片跳转
<%End If%>页</span><a href="<%=fileName%>?PageNo=<%=PageNo%>"><img src="../images/go.gif" width="37" height="15" border="0" /></a></div>
</form>
</td>

</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<%End Sub%>
街头小贩 2009-10-22
  • 打赏
  • 举报
回复
转向的按钮
的onclick事件取得input或select的当前值临时赋值给连接即可
伪代码
<input type="text" name="page" id="page" />
<input type="button" onclick="window.location.href=('当前的连接&page='+document.getElementById('page').value)" />

28,406

社区成员

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

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