注册 登录
编程论坛 ASP技术论坛

[求助]关于页码的问题

xinzheng 发布于 2007-08-17 19:53, 777 次点击

<%call PageControl(iCount,maxpage,page,"border=0 align=center","<p align=center class='zhengwen'>")


Sub PageControl(iCount,pagecount,page,table_style,font_style)
'生成上一页下一页链接
Dim query, a, x, temp
action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")

Dim t
t = ""
if pro_type <> 0 then t = t & "&pro_type=" & pro_type
if pro_type2 <> 0 then t = t & "&pro_type2=" & pro_type2
if pro_name <> "无" then t = t & "&keyword=" & Server.URLEncode(pro_name)

Response.Write("<table " & Table_style & ">" & vbCrLf )
Response.Write("<form method=get onsubmit=""document.location = '" & action & "?" & temp & "Page='+ this.page.value;return false;""><TR>" & vbCrLf )
Response.Write("<TD align=right>" & vbCrLf )
Response.Write(font_style & vbCrLf )

if page<=1 then
Response.Write ("首页 " & vbCrLf)
Response.Write ("上页 " & vbCrLf)
else
Response.Write("<A HREF=" & action & "?" & temp & "Page=1"& t &">首页</A> " & vbCrLf)
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page-1) & t &">上页</A> " & vbCrLf)
end if

if page>=pagecount then
Response.Write ("下页 " & vbCrLf)
Response.Write ("尾页 " & vbCrLf)
else
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page+1) & t &">下页</A> " & vbCrLf)
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & pagecount &t & ">尾页</A> " & vbCrLf)
end if

Response.Write(" 页次:" & page & "/" & pageCount & "页" & vbCrLf)
Response.Write(" 共有" & iCount & "种商品" & vbCrLf)
Response.Write(" 转到" & "<INPUT TYEP=TEXT NAME=page SIZE=1 Maxlength=5 VALUE=" & page & ">" &"页" & vbCrLf & "<INPUT type=submit style=""font-size: 9pt"" value=GO class=b2>")
Response.Write("</TD>" & vbCrLf )
Response.Write("</TR></form>" & vbCrLf )
Response.Write("</table>" & vbCrLf )
End Sub
%>

根据上面红色的蓝色的这段要怎么改?不然按回车或一点go就跳到大类的第几页了

[此贴子已经被作者于2007-8-17 22:08:02编辑过]

9 回复
#2
yms1232007-08-17 21:57
http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")
可能楼主的页面条转错误,估计跟红色的代码没什么关系。
#3
yms1232007-08-17 22:13
if pro_type <> 0 then t = t & "&pro_type=" & pro_type
if pro_type2 <> 0 then t = t & "&pro_type2=" & pro_type2
if pro_name <> "无" then t = t & "&keyword=" & Server.URLEncode(pro_name)
这些内容是某个网页的参数
action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")
这句话应该是取得当前页的URL
#4
xinzheng2007-08-17 22:13

我是说蓝色这段怎么改才能象前面上页,下页这样

#5
xinzheng2007-08-18 11:24
难道就没有人会改下吗??????????????、
#6
yms1232007-08-18 16:34

Dim t
t = ""
if Request("pro_type") <> 0 then t = t & "pro_type=" &Request("pro_type")
if Request("pro_type2") <> 0 then t = t & "pro_type2=" & Request("pro_type2")
if Request("pro_name") <> "无" then t = t & "keyword=" & Server.URLEncode(Request("pro_name"))

Response.Write("<table " & Table_style & ">" & vbCrLf )
Response.Write("<form method=get onsubmit=""document.location = '" & action & "?" & t & "&Page='+ this.page.value;return false;""><TR>" & vbCrLf )

试试看。

#7
xinzheng2007-08-18 19:39
没用,
Response.Write(" 转到" & "<INPUT TYEP=TEXT NAME=page SIZE=1 Maxlength=5 VALUE=" & page & ">" &"页" & vbCrLf & "<INPUT type=submit style=""font-size: 9pt"" value=GO class=b2>")

& page &这个不能改,能不能把这个手工输入页码换成下拉列表形式,那就能实现了,可我不知道怎么做下拉列表
#8
xinzheng2007-08-18 20:06
以下是引用yms123在2007-8-18 16:34:01的发言:

Dim t
t = ""
if Request("pro_type") <> 0 then t = t & "pro_type=" &Request("pro_type")
if Request("pro_type2") <> 0 then t = t & "pro_type2=" & Request("pro_type2")
if Request("pro_name") <> "无" then t = t & "keyword=" & Server.URLEncode(Request("pro_name"))

Response.Write("<table " & Table_style & ">" & vbCrLf )
Response.Write("<form method=get onsubmit=""document.location = '" & action & "?" & t & "&Page='+ this.page.value;return false;""><TR>" & vbCrLf )

试试看。

这段没用,受你启发,我现在想这么来,可不知道应该怎么写
<script language="javascript">
function selPage_Change(txt)
{
self.location="product.asp?Page="+txt+"&t&";
}
</script>

Response.Write(" 转到" & "<select name=""select"" onChange="selPage_Change(this.options[this.selectedIndex].text);">
"<%for i=1 to Pagecount %>
<option><%=i%></option>
<% next %>"
</select>
" & "页" & vbCrLf & )

我知道这样写是错的,请你写个对的好吗?我这样提示出错

[此贴子已经被作者于2007-8-18 20:06:52编辑过]

#9
xinzheng2007-08-18 22:13
回复:(xinzheng)以下是引用yms123在2007-8-18 16:3...

完整的代码是这样的

<% call PageControl(iCount,maxpage,page,"border=0 align=center","<p align=center>")
Sub PageControl(iCount,pagecount,page,table_style,font_style)
'生成上一页下一页链接
Dim query, a, x, temp
action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")

query = Split(Request.ServerVariables("QUERY_STRING"), "&")
For Each x In query
a = Split(x, "=")
If StrComp(a(0), "page", vbTextCompare) <> 0 Then
temp = temp & a(0) & "=" & a(1) & "&"
End If
Next

Response.Write("<table " & Table_style & ">" & vbCrLf )
Response.Write("<form method=get onsubmit=""document.location = '" & action & "?" & temp & "Page='+ this.page.value;return false;""><TR>" & vbCrLf )
Response.Write("<TD align=right>" & vbCrLf )
Response.Write(font_style & vbCrLf )

if page<=1 then
Response.Write ("首页 " & vbCrLf)
Response.Write ("上页 " & vbCrLf)
else
Response.Write("<A HREF=" & action & "?" & temp & "Page=1>首页</A> " & vbCrLf)
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page-1) & ">上页</A> " & vbCrLf)
end if

if page>=pagecount then
Response.Write ("下页 " & vbCrLf)
Response.Write ("尾页 " & vbCrLf)
else
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page+1) & ">下页</A> " & vbCrLf)
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & pagecount & ">尾页</A> " & vbCrLf)
end if

Response.Write(" 页次:" & page & "/" & pageCount & "页" & vbCrLf)
Response.Write(" 共有" & iCount & "种商品" & vbCrLf)
Response.Write(" 转到" & "<INPUT TYEP=TEXT NAME=page SIZE=1 Maxlength=5 VALUE=" & page & ">" & "页" & vbCrLf & "<INPUT type=submit style=""font-size: 9pt"" value=GO class=b2>")
Response.Write("</TD>" & vbCrLf )
Response.Write("</TR></form>" & vbCrLf )
Response.Write("</table>" & vbCrLf )
End Sub
%>

[此贴子已经被作者于2007-8-18 22:16:16编辑过]

#10
xinzheng2007-08-18 22:50
哈哈,终于被我搞定了

此问题结贴!!!!!!!!!!!!!!!!

[此贴子已经被作者于2007-8-18 22:56:55编辑过]

1