asp 无限分类问题,在线等

来源:百度知道 编辑:UC知道 时间:2024/06/03 05:35:53
无张分类已经做好了:

|-1级分类
|--2级分类
|---3级分类
|----4级分类
|----...n级分类

我想实现依次点击某一级类别才显示相应的下一级分类怎么做?

如:点“1级分类”展开“2级分类”,点“2级分类”展开“3级分类”依次逐层显示。。。。

注:不要用javascript
<table>

<%
set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from Class where ParentID=0"
rs.open sql,conn,1,1
i=1
do while not rs.eof
%>

<tr>
<td><a href="?classid=<%=Rs("classid")%>"><%=Rs("ClassName")%></a></td>
</tr></table>
<%
i=i+1
Rs.MoveNext
loop
Rs.Close
set Rs=nothing
%>

数据库结构:表:class

classid:自动id号
ParentID:父id号,ParentId为0的时候,代表一级分类
classname:分类名称

<%
'假设CategoryID 字段为ID ,呵呵是它太长了我懒得打字
temp=""
set rs1=Server.createObject("adodb.recordSet")
sq1="select * from category where FateherID=0" '显示第一级
rs1.open sq1,conn,1,1
While not rs1.eof
temp=temp&"<option value="&rs1("ID")>"&rs1("name")&"</option>"
temp=temp+vbcrlf '换行 --是为了代码好看点
temp=temp&searchChild(bb,rs1("CategoryID")) '添加它的儿子 bb是添加分割号
rs1.movenext
Wend
rs1.close
set rs1=nothing

function searchChild(tt,tid)
b="" '临时变量
set rst=server.createObject("Adodb.recordSet")
sq="select * from category where id="&tid
rst.open sq,conn1,1
IF rst.recordCount>0 then
while not rst.eof
tt=tt&"|"
b=b&"<option value="&rst("ID")>"&tt&"-"&rst("name")&&quo