读书人

ASP新手问一个初级有关问题,刚才结贴着

发布时间: 2012-08-27 21:21:57 作者: rapoo

ASP新手问一个初级问题,刚才结贴着急了
刚才结贴太快了,问题还没有解决彻底,只得再次发帖,

选定品牌后进入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>

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

数据库的结构是这样的

IDcarmoderidsubname partname
1奥迪 驾驶室 窗户
2奥迪 驾驶室 玻璃
3奥迪 发动机 发动机总成
4奥迪 发动机 燃油箱
5本田 驾驶室 窗户
6本田 驾驶室 玻璃
7本田 发动机 发动机总成
8本田 发动机 燃油箱


[解决办法]

HTML code
<!--#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.closeset 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=1else currentPage=request("p")end ifset rs=server.createobject("adodb.recordset")MaxPerPage=20sql="select * from DF_partable where 1=1 "if b<>"" then   sql=sql&" and carmoderid = '"&b&"'"   end ifif s<>"" and s<>"0" thensql=sql&" and subname = '"&s&"'"end ifsql=sql&" order by id desc"   rs.open sql,conn,1,1if rs.eof then mpage=1 allshu=0else i=0 rs.pagesize=MaxPerPage  mpage=rs.pagecount   rs.move (currentPage-1)*MaxPerPage allshu=rs.recordcountsearch="&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 loopend 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> 

读书人网 >ASP

热点推荐