递归分类点击上级类别才显示出下级类别怎么写?
id mc fid
1 珠心算 0
2 启蒙班 1
3 预备上 2
4 预备下 2
下面是列出分类的代码,请问要点击上级类别才显示出下级类别怎么写?而不是列出全部类别.如点击珠心算就显示出启蒙班,再点击一下珠心算就把启蒙班隐藏起来,同样的,点击启蒙班就显示出预备上和预备下,再点击一下启蒙班就隐藏预备上和预备下
<%
Function Echo(Str) '输出字符串并换行
Response.Write Str &"<br />"
End Function
Dim MyCount
MyCount = 0
Sub SubFl(FID)
Dim Rs1,sql1,i
sql1="select * from km where fid = "&FID&" order by Id"'查询类别
Set Rs1=server.createobject("adodb.recordset")
Rs1.open sql1,conn,1,1
If Not Rs1.Eof Then
MyCount = MyCount + 1 '流水号+1
Do While Not Rs1.Eof
For i = 1 to MyCount
If i = 1 then
Response.Write "+"
Else
Response.Write "----"
End If
Next
Response.Write " "
Echo(""&Rs1("mc"))
Call SubFl(Trim(Rs1("Id"))) '递归子级分类
Rs1.Movenext:Loop
If MyCount <> 0 Then'如果这个类没有子分类 就不需要减一
MyCount = MyCount - 1'没有下级分类 减1 继续查找上一级
End If
If Rs1.Eof Then
Rs1.Close
Exit Sub
End If
End If
Set Rs1 = Nothing
End Sub
Sub MainClass()
sql="select * from km where fid = 0 order by Id"'主分类搜索
Set Rs=server.createobject("adodb.recordset")
Rs.open sql,conn,1,3
If Not Rs.Eof Then
Do While Not Rs.Eof
Echo(""&Rs("mc"))
Call SubFl(Trim(Rs("Id"))) '递归子级分类
Rs.Movenext:Loop
Else
Response.Write "还没有分类"
End If
End Sub
Call MainClass()
%>
------解决方案--------------------------解决方案--------------------那个肯定是要通过JS操作的了