asp無限級分類支援js收縮伸展

來源:互聯網
上載者:User

<!-- #include file="adoconn.asp" -->
<style>
.dotted_class{
 border-bottom:1px dotted #757575;
}
.dotted_class a{
 text-decoration:none;
 font-size:12px;
}
.td{
 font-size:12px;
}
</style>
<script language="javascript教程">
  function $$(id)
  {
 return document.getElementById(id);
  }

function fd(id,num)
{
 t=$$("d_"+id).src;
 if(t.indexOf("+.gif")>0)
 {
   t1="block";
   t2="images/-.gif";
 }
 else
 {
  t1="none"; 
  t2="images/+.gif";
 }
 for(i=1;i<=num;i++)
 {
  $$("c"+id+"_"+i).style.display=t1;
  $$("d_"+id).src=t2;  
 }
}

</script>

<%
catstr=""
depath=0
Call cat111(0,0,2)
%>
<TABLE width="500">
<TR>
 <TD><%=catstr%></TD>
</TR>
</TABLE>
<%
function cat111(parent_id,tid,stype)
set rs1 =server.createobject("adodb.recordset")
sql="select cat_name,cat_id,parent_id from category where parent_id="&parent_id&" and u_id="&stype&" and is_show=1 order by cat_order asc"
set rs1=conn.execute(sql)
If rs1.eof Then
Else 
if(depath>2) then
 display2="none"     
else
 display2="block" 
end if  
dim j
j=1
do while not rs1.eof 
 cat_name1 = rs1("cat_name")
 cat_id1 = rs1("cat_id")  
 parent_id1=rs1("parent_id") 
 '******************下面是你要顯示的******************' 
 m9=0
 sql2="select count(cat_id) as t from category where parent_id="&cat_id1&" and u_id="&stype&""    
 set rs2=server.createobject("adodb.recordset")
 set rs2=conn.execute(sql2) 
 if not rs2.eof then
    m9=rs2("t")
 else
  m9=0  
 end if 
 rs2.close
  
 if(depath<=2) then  
  mgif="images/-.gif"
  a="block"
 else
  if(m9>0) then 
  mgif="images/+.gif" 
  else
  mgif="images/-.gif"
  end if
  if(depath=4) Then   
   a="block"   
  else  
   a="none"
  end if
 end If
 If cat_id1=8 or cat_id1=10 Then
  a="block"
  mgif="images/+.gif"
 ElseIf cat_id1>82 Then
  a="none"
  mgif="images/-.gif"  
 else 
 End if
 catstr=catstr & "<tr id=""c"&parent_id&"_"&j&""" style=""display:"&a&"""><td width=""5"" align=""center"" valign=""middle"" class=""dotted_class"">&nbsp;</td><td class=""dotted_class leftcatcss教程"">"
 for i=1 to depath
   catstr=catstr&"&nbsp;"
 Next
 catstr=catstr&"<img src="""&mgif&""" width=""12"" height=""11"" id=""d_"&cat_id1&""">&nbsp;"
 if(m9>0) then
  catstr=catstr&"<a href=""javascript:void(0);"" onclick=""fd("&cat_id1&","&m9&",0)"">" &vbnewline
 else
  catstr=catstr&"<a href=""products.asp?id="&cat_id1&""">"&vbnewline
 end if 
 If depath=0 Then
  cat_name1="<span style=""font-size:13px; font-weight:bold;"">"&cat_name1&"</span>"
 End If  
 catstr=catstr&cat_name1&"</a></td></tr>"&vbnewline
 m9=0
     
 sql2="select cat_name,cat_id from category where parent_id="&parent_id1&" and u_id="&stype&" order by cat_order asc"    
 set rs2=server.createobject("adodb.recordset")
 set rs2=conn.execute(sql2)
 if not rs2.eof then
    depath=depath+4 
    call cat111(cat_id1,tid,stype)
 end if
 rs2.close 
 set rs2=nothing 
 depath=depath-4 
 '******************上面是你要顯示的******************'
 j=j+1
rs1.movenext
loop


End If
rs1.close
set rs1=nothing
end Function
%>

資料庫教程串連檔案adoconn.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
response.Charset="utf-8"
response.codepage="65001"

DB="db1.mdb"

path=Server.MapPath(DB)
set conn=server.createobject("adodb.Connection")
connstr="provider=Microsoft.Jet.OLEDB.4.0;Data Source="&path
conn.Open connstr
Set rs=server.CreateObject("adodb.recordset")
%>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.