ASP新手问一个初级问题,刚才结贴着急了

dayuxiansheng 2012-08-24 11:53:52
刚才结贴太快了,问题还没有解决彻底,只得再次发帖,

选定品牌后进入df_car.asp页面,比如“df_car.asp?b=奥迪”,默认显示所属奥迪的所有partname列表,并进行分页,上面有一个subname下拉框进行筛选,默认是不限,如果选择“驾驶室”,则页面变成“df_car.asp?b=奥迪&s=驾驶室”,列表里显示的是进行筛选后的partname内容。现在的问题有两个
1.下拉分组,默认不限,默认显示所有分组,我下拉选择分组显示内容是对的,但是我在选回“不限”,也就是s=0,则一个都不显示了。
2.分页的问题,下一页上一页都没有了原来页面的的"b" "s" 数值。

<!--#include file="conn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="css/link.css" rel="stylesheet" type="text/css">
<script type=text/javascript language=javascript src="js/sethome.js"></script>
</head>
<body>

<%

s=request.QueryString("s")
b=trim(request("b"))

sqlprod="select * from DF_partable where carmoderid = '"&b&"' order by id desc"
%>

<div class="tag">
<td><form name="form1" action="df_car.asp" method="get" style="margin:0px;padding:0px;">
<%
Set rsprod=Server.CreateObject("ADODB.RecordSet")
rsprod.open sqlprod,conn,1,1

%>

所选品牌<%=rsprod("carmoderid")%>
: <input type="hidden" name="b" value="<%=rsprod("carmoderid")%>"/>

 


<%
rsprod.close
set rsprod=nothing
%>

分组:<select name="s">
<option value="0">--不限--</option>
<option value=发动机总成部分 <%if s="发动机总成部分" then%> selected="selected" <%end if%>>发动机总成部分</option>
<option value=发动机系统部分 <%if s="发动机系统部分" then%> selected="selected" <%end if%>>发动机系统部分</option>
<option value=离合器、变速箱、传动轴 <%if s="离合器、变速箱、传动轴" then%> selected="selected" <%end if%>>离合器、变速箱、传动轴</option>
<option value=车架、悬架部分 <%if s="车架、悬架部分" then%> selected="selected" <%end if%>>车架、悬架部分</option>
<option value=前轴、后桥部分 <%if s="前轴、后桥部分" then%> selected="selected" <%end if%>>前轴、后桥部分</option>
<option value=车轮、转向、制动部分 <%if s="车轮、转向、制动部分" then%> selected="selected" <%end if%>>车轮、转向、制动部分</option>
<option value=电器工具部分 <%if s="电器工具部分" then%> selected="selected" <%end if%>>电器工具部分</option>
<option value=驾驶室部分 <%if s="驾驶室部分" then%> selected="selected" <%end if%>>驾驶室部分</option>

</select>  



<input type="submit" value="筛选">
</form>
</div>

<div class="pagerank_list">
<tr>

</tr>
</table>


<%
if request("p")="" then
currentPage=1
else
currentPage=request("p")
end if
set rs=server.createobject("adodb.recordset")
MaxPerPage=20
sql="select * from DF_partable where 1=1 "

if b<>"" then
sql=sql&" and carmoderid = '"&b&"'"
end if

if s<>"" then
sql=sql&" and subname = '"&s&"'"
end if

sql=sql&" order by id desc"
rs.open sql,conn,1,1
if rs.eof then
mpage=1
allshu=0
else
i=0
rs.pagesize=MaxPerPage
mpage=rs.pagecount
rs.move (currentPage-1)*MaxPerPage
allshu=rs.recordcount

pageno=currentPage
if cint(pageno)>1 then
pagefy=pagefy&"<a href='?p=1"&search&"' title='首页'>首页</a>"
end if

if cint(pageno)>1 then
if cint(pageno)-1<2 then
pagefy=pagefy&"<a href='?p=1"&search&"' title='上一页'>上一页</a>"
else
pagefy=pagefy&"<a href='?p="&cint(pageno)-1 &search&"' title='上一页'>上一页</a>"
end if
end if

if cint(pageno)< mpage then

pagefy=pagefy&"<a href='?p="&pageno+1 &search&"' title='下一页'>下一页</a>"
pagefy=pagefy&"<a href='?p="&mpage &search&"' title='尾页'>尾页</a>"
end if

pagefy=pagefy&"<span>第"&pageno&"/"&mpage&"页</span> <a>"&MaxPerPage&"条/页</a> <a>共"&allshu&"条</a>"

%>

<div class="class_">
<div class="class_name"> </div>
<DIV class=post></DIV></div>
<table width="960" height="29" border="0" align="center" cellpadding="1" cellspacing="0" style=" border:#CBD7DE solid 1px;BACKGROUND: #ffffff; ">
<tr class="title">

<td width="130" >主组</td>
<td width="160" >子组</td>
<td width="30" >配件</td>

<%
do while not rs.eof
%>
<tr class="tr1" id="tr1_<%=i%>" onMouseOut="this.style.backgroundColor=''" onMouseOver="this.style.backgroundColor='#f0f0f0'" style="CURSOR: hand">

<td width="130" height="24"> <%=rs("subname")%></td>
<td width="160">

<%=rs("partname")%>
</td>
<td width="30">

点选
</td>
</tr>
<% rs.movenext
if i>=MaxPerPage then exit do
i=i+1
loop
end if
%>

</table>
<table width="960" border="0" align="center" cellpadding="0" cellspacing="0" style="margin-top:3px;border:#CBD7DE solid 1px;" background="images/menubg.gif">
<tr><td>
<div class='page_number'>
<%=pagefy%>
</div>
</td>
</tr>
</table>

</body>
</html>

————————————————————————————————————
刚才我发过帖子的内容
————————————————————————————————————

数据库的结构是这样的

ID carmoderid subname partname
1 奥迪 驾驶室 窗户
2 奥迪 驾驶室 玻璃
3 奥迪 发动机 发动机总成
4 奥迪 发动机 燃油箱
5 本田 驾驶室 窗户
6 本田 驾驶室 玻璃
7 本田 发动机 发动机总成
8 本田 发动机 燃油箱
...全文
114 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
AMinfo 2012-08-24
  • 打赏
  • 举报
回复

<!--#include file="conn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="css/link.css" rel="stylesheet" type="text/css">
<script type=text/javascript language=javascript src="js/sethome.js"></script>
</head>
<body>

<%

s=request("s")
b=trim(request("b"))

sqlprod="select * from DF_partable where carmoderid = '"&b&"' order by id desc"
%>

<div class="tag">
<td><form name="form1" action="df_car.asp" method="get" style="margin:0px;padding:0px;">
<%
Set rsprod=Server.CreateObject("ADODB.RecordSet")
rsprod.open sqlprod,conn,1,1

%>

所选品牌<%=rsprod("carmoderid")%>
: <input type="hidden" name="b" value="<%=rsprod("carmoderid")%>"/>

 


<%
rsprod.close
set rsprod=nothing
%>

分组:<select name="s">
<option value="0">--不限--</option>
<option value=发动机总成部分 <%if s="发动机总成部分" then%> selected="selected" <%end if%>>发动机总成部分</option>
<option value=发动机系统部分 <%if s="发动机系统部分" then%> selected="selected" <%end if%>>发动机系统部分</option>
<option value=离合器、变速箱、传动轴 <%if s="离合器、变速箱、传动轴" then%> selected="selected" <%end if%>>离合器、变速箱、传动轴</option>
<option value=车架、悬架部分 <%if s="车架、悬架部分" then%> selected="selected" <%end if%>>车架、悬架部分</option>
<option value=前轴、后桥部分 <%if s="前轴、后桥部分" then%> selected="selected" <%end if%>>前轴、后桥部分</option>
<option value=车轮、转向、制动部分 <%if s="车轮、转向、制动部分" then%> selected="selected" <%end if%>>车轮、转向、制动部分</option>
<option value=电器工具部分 <%if s="电器工具部分" then%> selected="selected" <%end if%>>电器工具部分</option>
<option value=驾驶室部分 <%if s="驾驶室部分" then%> selected="selected" <%end if%>>驾驶室部分</option>
</select>  



<input type="submit" value="筛选">
</form>
</div>

<div class="pagerank_list">
<tr>

</tr>
</table>


<%
if request("p")="" then
currentPage=1
else
currentPage=request("p")
end if
set rs=server.createobject("adodb.recordset")
MaxPerPage=20
sql="select * from DF_partable where 1=1 "

if b<>"" then
sql=sql&" and carmoderid = '"&b&"'"
end if

if s<>"" and s<>"0" then
sql=sql&" and subname = '"&s&"'"
end if

sql=sql&" order by id desc"
rs.open sql,conn,1,1
if rs.eof then
mpage=1
allshu=0
else
i=0
rs.pagesize=MaxPerPage
mpage=rs.pagecount
rs.move (currentPage-1)*MaxPerPage
allshu=rs.recordcount

search="&b="&b&"&s="&s
pageno=currentPage
if cint(pageno)>1 then
pagefy=pagefy&"<a href='?p=1"&search&"' title='首页'>首页</a>"
end if

if cint(pageno)>1 then
if cint(pageno)-1<2 then
pagefy=pagefy&"<a href='?p=1"&search&"' title='上一页'>上一页</a>"
else
pagefy=pagefy&"<a href='?p="&cint(pageno)-1 &search&"' title='上一页'>上一页</a>"
end if
end if

if cint(pageno)< mpage then

pagefy=pagefy&"<a href='?p="&pageno+1 &search&"' title='下一页'>下一页</a>"
pagefy=pagefy&"<a href='?p="&mpage &search&"' title='尾页'>尾页</a>"
end if

pagefy=pagefy&"<span>第"&pageno&"/"&mpage&"页</span> <a>"&MaxPerPage&"条/页</a> <a>共"&allshu&"条</a>"

%>

<div class="class_">
<div class="class_name"> </div>
<DIV class=post></DIV></div>
<table width="960" height="29" border="0" align="center" cellpadding="1" cellspacing="0" style=" border:#CBD7DE solid 1px;BACKGROUND: #ffffff; ">
<tr class="title">

<td width="130" >主组</td>
<td width="160" >子组</td>
<td width="30" >配件</td>

<%
do while not rs.eof
%>
<tr class="tr1" id="tr1_<%=i%>" onMouseOut="this.style.backgroundColor=''" onMouseOver="this.style.backgroundColor='#f0f0f0'" style="CURSOR: hand">

<td width="130" height="24"> <%=rs("subname")%></td>
<td width="160">

<%=rs("partname")%>
</td>
<td width="30">

点选
</td>
</tr>
<% rs.movenext
if i>=MaxPerPage then exit do
i=i+1
loop
end if
%>

</table>
<table width="960" border="0" align="center" cellpadding="0" cellspacing="0" style="margin-top:3px;border:#CBD7DE solid 1px;" background="images/menubg.gif">
<tr><td>
<div class='page_number'>
<%=pagefy%>
</div>
</td>
</tr>
</table>

</body>
</html>

dayuxiansheng 2012-08-24
  • 打赏
  • 举报
回复
2楼的朋友您好,谢谢您,你帮我解决了第二个分页问题,但是第一个问题还是没有解决,我举个例子,我进入这个页面是“df_car.asp?b=奥迪”,这时候显示的内容是对的,下拉菜单我选择其中任意一个列出的内容都是对的,比如“df_car.asp?b=奥迪&s=驾驶室”,但当我再次选第一个“不限”的时候,正常应该列出我刚进入这个页面的内容,可是这是页面时“df_car.asp?b=奥迪&s=0”,列表没有内容,而且下拉菜单也没有了内容。不知道我说明白没有。
AMinfo 2012-08-24
  • 打赏
  • 举报
回复

<!--#include file="conn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="css/link.css" rel="stylesheet" type="text/css">
<script type=text/javascript language=javascript src="js/sethome.js"></script>
</head>
<body>

<%

s=request("s")
b=trim(request("b"))

sqlprod="select * from DF_partable where carmoderid = '"&b&"' order by id desc"
%>

<div class="tag">
<td><form name="form1" action="df_car.asp" method="get" style="margin:0px;padding:0px;">
<%
Set rsprod=Server.CreateObject("ADODB.RecordSet")
rsprod.open sqlprod,conn,1,1

%>

所选品牌<%=rsprod("carmoderid")%>
: <input type="hidden" name="b" value="<%=rsprod("carmoderid")%>"/>

 


<%
rsprod.close
set rsprod=nothing
%>

分组:<select name="s">
<option value="0">--不限--</option>
<%If s<>"0" Then%>
<option value=发动机总成部分 <%if s="发动机总成部分" then%> selected="selected" <%end if%>>发动机总成部分</option>
<option value=发动机系统部分 <%if s="发动机系统部分" then%> selected="selected" <%end if%>>发动机系统部分</option>
<option value=离合器、变速箱、传动轴 <%if s="离合器、变速箱、传动轴" then%> selected="selected" <%end if%>>离合器、变速箱、传动轴</option>
<option value=车架、悬架部分 <%if s="车架、悬架部分" then%> selected="selected" <%end if%>>车架、悬架部分</option>
<option value=前轴、后桥部分 <%if s="前轴、后桥部分" then%> selected="selected" <%end if%>>前轴、后桥部分</option>
<option value=车轮、转向、制动部分 <%if s="车轮、转向、制动部分" then%> selected="selected" <%end if%>>车轮、转向、制动部分</option>
<option value=电器工具部分 <%if s="电器工具部分" then%> selected="selected" <%end if%>>电器工具部分</option>
<option value=驾驶室部分 <%if s="驾驶室部分" then%> selected="selected" <%end if%>>驾驶室部分</option>
<%End If%>
</select>  



<input type="submit" value="筛选">
</form>
</div>

<div class="pagerank_list">
<tr>

</tr>
</table>


<%
if request("p")="" then
currentPage=1
else
currentPage=request("p")
end if
set rs=server.createobject("adodb.recordset")
MaxPerPage=20
sql="select * from DF_partable where 1=1 "

if b<>"" then
sql=sql&" and carmoderid = '"&b&"'"
end if

if s<>"" then
sql=sql&" and subname = '"&s&"'"
end if

sql=sql&" order by id desc"
rs.open sql,conn,1,1
if rs.eof then
mpage=1
allshu=0
else
i=0
rs.pagesize=MaxPerPage
mpage=rs.pagecount
rs.move (currentPage-1)*MaxPerPage
allshu=rs.recordcount

search="&b="&b&"&s="&s
pageno=currentPage
if cint(pageno)>1 then
pagefy=pagefy&"<a href='?p=1"&search&"' title='首页'>首页</a>"
end if

if cint(pageno)>1 then
if cint(pageno)-1<2 then
pagefy=pagefy&"<a href='?p=1"&search&"' title='上一页'>上一页</a>"
else
pagefy=pagefy&"<a href='?p="&cint(pageno)-1 &search&"' title='上一页'>上一页</a>"
end if
end if

if cint(pageno)< mpage then

pagefy=pagefy&"<a href='?p="&pageno+1 &search&"' title='下一页'>下一页</a>"
pagefy=pagefy&"<a href='?p="&mpage &search&"' title='尾页'>尾页</a>"
end if

pagefy=pagefy&"<span>第"&pageno&"/"&mpage&"页</span> <a>"&MaxPerPage&"条/页</a> <a>共"&allshu&"条</a>"

%>

<div class="class_">
<div class="class_name"> </div>
<DIV class=post></DIV></div>
<table width="960" height="29" border="0" align="center" cellpadding="1" cellspacing="0" style=" border:#CBD7DE solid 1px;BACKGROUND: #ffffff; ">
<tr class="title">

<td width="130" >主组</td>
<td width="160" >子组</td>
<td width="30" >配件</td>

<%
do while not rs.eof
%>
<tr class="tr1" id="tr1_<%=i%>" onMouseOut="this.style.backgroundColor=''" onMouseOver="this.style.backgroundColor='#f0f0f0'" style="CURSOR: hand">

<td width="130" height="24"> <%=rs("subname")%></td>
<td width="160">

<%=rs("partname")%>
</td>
<td width="30">

点选
</td>
</tr>
<% rs.movenext
if i>=MaxPerPage then exit do
i=i+1
loop
end if
%>

</table>
<table width="960" border="0" align="center" cellpadding="0" cellspacing="0" style="margin-top:3px;border:#CBD7DE solid 1px;" background="images/menubg.gif">
<tr><td>
<div class='page_number'>
<%=pagefy%>
</div>
</td>
</tr>
</table>

</body>
</html>

dayuxiansheng 2012-08-24
  • 打赏
  • 举报
回复
多谢楼上的。

28,409

社区成员

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

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