| 
                        
                            |  当前位置:文章中心 >> 成都网站建设_成都网页设计 |  
                        
                            | 
                                    
                                        | ASP无限级分类实例教程 |  
                                        | 夜鹰教程网 来源:www.yyjcw.com                                      日期:2016-11-5 21:58:20 |  
                                    
                                        | 为了方便使用分类,我定义了一个分类表category,里面字段是 |  
                                    
                                        | 
 这篇文章不能解决你的问题?我们还有相关视频教程云课堂 全套前端开发工程师培训课程 微信号:yyjcw10000 QQ:1416759661  远程协助需要加QQ! 业务范围:视频教程|程序开发|在线解答|Demo制作|远程调试| 点击查看相关的视频教程。 技术范围:全端开发/前端开发/webapp/web服务/接口开发/单片机/C#/java/node/sql server/mysql/mongodb/android/。  
 
 |  
                                    
                                        | <script> function fd(id,num)
 {
 t=$("c"+id+"_1").style.display;
 
 if(t=="none")
 {
 t1="block";
 t2="images/fll_34.gif";
 }
 else
 {
 t1="none";
 t2="images/fll_34.gif";
 }
 for(i=1;i<=num;i++)
 {
 $("c"+id+"_"+i).style.display=t1;
 $("d_"+id).src=t2;
 }
 }
 function $(id)
 {
 return document.getElementById(id);
 }
 </script>
 这是asp无限级显示分类代码,并给这些分类加上id
 
 <%
 '功能:asp无限级显示分类+js显示与隐藏
 '参数:parent_id为父ID,stype为新闻,产品,文章大分类
 '原创文章,转载请保留些信息,谢谢
 function cat111(parent_id,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
 
 
 catstr=catstr & "<tr id=""c"&parent_id&"_"&j&""" style=""display:"&a&"""><td width=""25"" align=""center"" valign=""middle"" class=""dotted_class""><img src="""&mgif&""" width=""12"" height=""11"" id=""d_"&cat_id1&"""></td><td class=""dotted_class leftcatcss"">"
 if(m9>0) then
 catstr=catstr&"<a href=""javascript:void(0);"" _fcksavedurl="""javascript:void(0);""" _fcksavedurl="""javascript:void(0);""" onclick=""fd("&cat_id1&","&m9&")"">" &vbnewline
 else
 catstr=catstr&"<a href=""products.asp?id="&cat_id1&""" target=""_blank"">"&vbnewline
 end if
 for i=1 to depath
 catstr=catstr&" "
 Next
 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,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
 %>
 在使用这个函数之前加上
 catstr=""
 然后再call,下面的虚线加在css中的dotted_class里面,这样就搞定了。
 注意:这里得到的是一个表格的行,要和其他行放在一起,不要加到td里面去了。
 |  | 
                                    
                                        |  热门服务/教程目录 |  
                                        | 
 
                                                 客服电话:153 9760 0032购买教程QQ:1416759661 |  |  |