制作了一个ASP分页程序,在显示本页记录后rs.AbsolutePage会自动加1,为什么会这样,而翻页链接是根据rs.AbsolutePage而变,rs.AbsolutePage值与显示出来的页面数值不同?请问错在哪里:
<script language=javascript>
//点击"[第一页]"时响应:
function PageFirst()
{
document.form1.CurrentPage.selectedIndex=0;
document.form1.CurrentPage.onchange();
}
//点击"[上一页]"时响应:
function PagePrior()
{
document.form1.CurrentPage.selectedIndex--;
document.form1.CurrentPage.onchange();
}
//点击"[下一页]"时响应:
function PageNext()
{
document.form1.CurrentPage.selectedIndex++;
document.form1.CurrentPage.onchange();
}
//点击"[最后一页]"时响应:
function PageLast()
{
document.form1.CurrentPage.selectedIndex=document.form1.CurrentPage.length-1;
document.form1.CurrentPage.onchange();
}
//选择"第?页"时响应:
function PageCurrent()
{ //data_list.asp是本程序的文件名
document.form1.action='data_list.asp?Page='+(document.form1.CurrentPage.selectedIndex+1)
document.form1.submit();
}
</Script>
<%
data_progress="完成"
data_exam=false
set rs=server.createobject("adodb.recordset")
rs.CursorLocation=adUseClient
rs.PageSize=5
sql = "select * from dtp_data where data_progress='"&data_progress&"' and data_exam="&data_exam&" order by data_date_end asc"
rs.open sql,conn,1,1
total=rs.recordcount
%>
<form name="form1" method="post">
<%IF rs.Eof THEN
Response.Write("<font size=2 color=#000080>[数据库中没有记录!]</font>")
ELSE
If Request("CurrentPage")="" Then
rs.AbsolutePage=1
Else
rs.AbsolutePage=CLng(Request.form("CurrentPage"))
End If
%>
'显示表头
<%For i=1 to rs.PageSize%> '循环显示本页记录
'显示记录内容
<%
rs.movenext
if rs.eof then exit for
Next
%>
''翻页超链接
<%
Response.Write("第<select size=1 name=CurrentPage onchange=PageCurrent()>")
For c=1 to rs.PageCount
if rs.AbsolutePage=c then
Response.Write("<option selected>"&c&"</option>") ''当前页码
else
Response.Write("<option>"&c&"</option>")
end if
Next
Response.Write("</select>页 ")
if rs.PageCount=1 then
Response.Write("[第一页] [上一页] [下一页] [最后一页] ")
else
if rs.AbsolutePage=1 then
Response.Write("[第一页] [上一页] ")
Response.Write("[<a href=javascript:PageNext()>下一页</a>] ")
Response.Write("[<a href=javascript:PageLast()>最后一页</a>] ")
else
if rs.AbsolutePage=rs.PageCount then
Response.Write("[<a href=javascript:PageFirst()>第一页</a>] ")
Response.Write("[<a href=javascript:PagePrior()>上一页</a>] ")
Response.Write("[下一页] [最后一页] ")
else
Response.Write("[<a href=javascript:PageFirst()>第一页</a>] ")
Response.Write("[<a href=javascript:PagePrior()>上一页</a>] ")
Response.Write("[<a href=javascript:PageNext()>下一页</a>] ")
Response.Write("[<a href=javascript:PageLast()>最后一页</a>] ")
end if
end if
end if
response.write rs.AbsolutePage
response.write request("page")
rs.close
set rs=nothing
end if
%>
</form>
[此贴子已经被作者于2006-3-29 21:04:22编辑过]