分页显示上一页,下一页,首页,尾页链接传值出现问题 10
我编了一个将一篇长文章进行分页显示的程序,虽然能实现分页了,但是"上一页,下一页,首页,尾页'不能进行很好的传值链接,当显示第二,三,四等页时,点击下一页,尾页,没有反应...
我编了一个将一篇长文章进行分页显示的程序,虽然能实现分页了,但是"上一页,下一页,首页,尾页'不能进行很好的传值链接,当显示第二,三,四等页时,点击下一页,尾页,没有反应,点上一页,直接就回到首页了
程序代码如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language="vbscript">
sub aa()
if windows.event.keycode=13 then
page=document.frompage.pageno.value
windows.location.href="xianshi.asp?pageno=<%=page%>"
end if
end sub
</script>
</head>
<%
dim conn,rs,sql,pageno,length,totalpage,currentpage
const words=10
length=len("可可靠六零六看来可可靠六零六看来可可靠六零六看来可可靠六零六看来可可靠六零六看来可可靠六零六看来可可靠六零六看来可可靠六零六看来可可靠六零六看来可可靠六零六看来可可靠六零六看来可可靠六零六看来")
totalpage=Clng(length/words)
set conn=Server.CreateObject("adodb.connection")
conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("wzh.mdb")
conn.open
sql="select * from aa"
set rs=Server.CreateObject("adodb.recordset")
rs.open sql,conn,1,3
'Response.write(mid(rs("content"),1,20))
if request("pageno")="" then
currentpage=1
else
currentpage=Clng( request("pageno"))
end if
rs.absolutepage= currentpage
' response.Write (rs.absolutepage)
'rs.absolutepage=pageno
%>
<body>
<center>
<font size="4" color="#FF0000">显示的文章</font><BR>
<form name="formpage">
<%
response.Write "共有"&totalpage&"页,第"¤tpage&"/"&totalpage&"页"
if currentpage=1 then
response.Write("[上一页]")
else
%>
[<a href="xianshi.asp"?pageno=<%=currentpage-1%>>上一页</a>]
<%
end if
if currentpage=totalpage then
response.write"[下一页]"
else
%>
[<a href="xianshi.asp"?pageno=<%=currentpage-1%>>下一页</a>]
<%
end if
if currentpage>1 then
%>
[<a href="xianshi.asp"?pageno=1>首页</a>]
<%
else
response.write"[首页]"
end if
if currentpage<totalpage then
%>
[<a href="xianshi.asp"?pageno=<%=totalpage%>>尾页</a>]
<%
else
response.write"[尾页]"
end if
%>
第<input type="text" size="4" name="pageno" onKeyPress=aa()>页
<table align="center" border="0" height="500">
<tr>
<td>
<%
dim start
start=(currentpage-1)*words+1
'start=(rs.absolutepage-1)*words+1
'Response.write(currentpage)
'response.write(star)
response.write(mid(rs("content"),start,words))
'Response.write(mid(rs("content"),1,20))
'response.write(mid(rs("content"),1,words))
rs.close
conn.close
%>
</td>
</tr>
</table>
</form>
</body>
</html> 展开
程序代码如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language="vbscript">
sub aa()
if windows.event.keycode=13 then
page=document.frompage.pageno.value
windows.location.href="xianshi.asp?pageno=<%=page%>"
end if
end sub
</script>
</head>
<%
dim conn,rs,sql,pageno,length,totalpage,currentpage
const words=10
length=len("可可靠六零六看来可可靠六零六看来可可靠六零六看来可可靠六零六看来可可靠六零六看来可可靠六零六看来可可靠六零六看来可可靠六零六看来可可靠六零六看来可可靠六零六看来可可靠六零六看来可可靠六零六看来")
totalpage=Clng(length/words)
set conn=Server.CreateObject("adodb.connection")
conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("wzh.mdb")
conn.open
sql="select * from aa"
set rs=Server.CreateObject("adodb.recordset")
rs.open sql,conn,1,3
'Response.write(mid(rs("content"),1,20))
if request("pageno")="" then
currentpage=1
else
currentpage=Clng( request("pageno"))
end if
rs.absolutepage= currentpage
' response.Write (rs.absolutepage)
'rs.absolutepage=pageno
%>
<body>
<center>
<font size="4" color="#FF0000">显示的文章</font><BR>
<form name="formpage">
<%
response.Write "共有"&totalpage&"页,第"¤tpage&"/"&totalpage&"页"
if currentpage=1 then
response.Write("[上一页]")
else
%>
[<a href="xianshi.asp"?pageno=<%=currentpage-1%>>上一页</a>]
<%
end if
if currentpage=totalpage then
response.write"[下一页]"
else
%>
[<a href="xianshi.asp"?pageno=<%=currentpage-1%>>下一页</a>]
<%
end if
if currentpage>1 then
%>
[<a href="xianshi.asp"?pageno=1>首页</a>]
<%
else
response.write"[首页]"
end if
if currentpage<totalpage then
%>
[<a href="xianshi.asp"?pageno=<%=totalpage%>>尾页</a>]
<%
else
response.write"[尾页]"
end if
%>
第<input type="text" size="4" name="pageno" onKeyPress=aa()>页
<table align="center" border="0" height="500">
<tr>
<td>
<%
dim start
start=(currentpage-1)*words+1
'start=(rs.absolutepage-1)*words+1
'Response.write(currentpage)
'response.write(star)
response.write(mid(rs("content"),start,words))
'Response.write(mid(rs("content"),1,20))
'response.write(mid(rs("content"),1,words))
rs.close
conn.close
%>
</td>
</tr>
</table>
</form>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询