假设菜单页为left.asp,产品页为product.asp
left.asp源码如下:
<
table width
=
"
100%
"
border
=
"
0
"
cellspacing
=
"
0
"
cellpadding
=
"
0
"
>
< %
sql = " select * from class1 order by Class1Id asc " ' 读出大类
set sortRootRs = conn.execute (sql)
i = 0
do while not (sortRootRs.eof or err)
sortRootRsID = sortRootRs( " class1id " )
% >
< tr >
< td height = " 18 " align = " left " valign = " top " background = " images/pole_1.jpg " >< div style = " padding-left:12px; padding-top:0px " >
< a href = " products.asp?class1id=<%=sortRootRs( " class1id " )%> " >< span class = " style6 " > < % = sortRootRs( " class1name " )% ></ span ></ a > ' 显示大类列表
</ div ></ td >
</ tr >
< tr id = child < % = sortRootRsID% > style = ' display:none'>'小类列表用样式控制它默认不显示
< td height = " 18 " align = " left " valign = " top " background = " images/pole_2.jpg " >
< %
sql = " select * from class2 where class1ID= " & sortRootRs( " class1id " ) & " order by Class2Id asc " ' 读出小类
set sortChildRs = server.createObject( " adodb.recordset " )
sortChildRs.open sql,conn, 1 , 1
j = 1
' k=sortchildRs.recordcount
do while not (sortChildRs.eof or err)
% >
< div style = " padding-left:12px; padding-top:0px;line-height:18px; " >
< a href = " products.asp?class1id=<%=sortRootRs( " class1id " )%>&class2id=<%=sortChildRs( " class2id " )%> " class = " style7 " style = " text-decoration:none " >< % = sortChildRs( " class2name " )% ></ a >
</ div >
< %j = j + 1
' if j>100 then exit do
sortChildRs.moveNext
loop % > ' 小类循环
</ td >
</ tr >
< %
i = i + 1
if i > 100 then exit do
sortRootRs.moveNext
loop
% > ' 大类循环
</ table >
< %
sql = " select * from class1 order by Class1Id asc " ' 读出大类
set sortRootRs = conn.execute (sql)
i = 0
do while not (sortRootRs.eof or err)
sortRootRsID = sortRootRs( " class1id " )
% >
< tr >
< td height = " 18 " align = " left " valign = " top " background = " images/pole_1.jpg " >< div style = " padding-left:12px; padding-top:0px " >
< a href = " products.asp?class1id=<%=sortRootRs( " class1id " )%> " >< span class = " style6 " > < % = sortRootRs( " class1name " )% ></ span ></ a > ' 显示大类列表
</ div ></ td >
</ tr >
< tr id = child < % = sortRootRsID% > style = ' display:none'>'小类列表用样式控制它默认不显示
< td height = " 18 " align = " left " valign = " top " background = " images/pole_2.jpg " >
< %
sql = " select * from class2 where class1ID= " & sortRootRs( " class1id " ) & " order by Class2Id asc " ' 读出小类
set sortChildRs = server.createObject( " adodb.recordset " )
sortChildRs.open sql,conn, 1 , 1
j = 1
' k=sortchildRs.recordcount
do while not (sortChildRs.eof or err)
% >
< div style = " padding-left:12px; padding-top:0px;line-height:18px; " >
< a href = " products.asp?class1id=<%=sortRootRs( " class1id " )%>&class2id=<%=sortChildRs( " class2id " )%> " class = " style7 " style = " text-decoration:none " >< % = sortChildRs( " class2name " )% ></ a >
</ div >
< %j = j + 1
' if j>100 then exit do
sortChildRs.moveNext
loop % > ' 小类循环
</ td >
</ tr >
< %
i = i + 1
if i > 100 then exit do
sortRootRs.moveNext
loop
% > ' 大类循环
</ table >
product.asp
<
script language
=
Javascript
>
< ! --
function window_onload(i){
childSort = document.all( " child " + i);
// theTd = document.all( " td " + i);
if (childSort.style.display == " none " ){
// theTd.bgcolor = " #ffffff " ;
childSort.style.display = "" ;}
else {
// theTd.bgcolor = " #000000 " ;
childSort.style.display = " none " ;}
}
//-->
</ script >
< html >
< body onload = " window_onload(<%=class1id%>) " >
< ! -- #include file = " left.asp " -->
</ body >
</ html >
< ! --
function window_onload(i){
childSort = document.all( " child " + i);
// theTd = document.all( " td " + i);
if (childSort.style.display == " none " ){
// theTd.bgcolor = " #ffffff " ;
childSort.style.display = "" ;}
else {
// theTd.bgcolor = " #000000 " ;
childSort.style.display = " none " ;}
}
//-->
</ script >
< html >
< body onload = " window_onload(<%=class1id%>) " >
< ! -- #include file = " left.asp " -->
</ body >
</ html >
如果您觉得以上内容对您有所帮助,请支持以下链接Http://www.lvyedianzi.com