ASP 递归显示无穷树状结构, 下拉框中显示树状效果

 

   ASP 递归显示无穷树状结构, 下拉框中显示树状效果_第1张图片 ASP 递归显示无穷树状结构, 下拉框中显示树状效果_第2张图片

 

 

<% Sub ShowCategoryByParentId(varPid) Dim strSql,rsC strSql = "select * from vProCategory where pbCategoryParentId = " & varPid &" order by pbCategoryName" Set rsC=server.CreateObject("adodb.recordset") rsC.CursorLocation = 3 rsC.Open strSql,conn,3,3 'Response.Write(strSql & "
") If rsC.recordcount > 0 Then Response.write("

") Do until rsC.eof 'Response.Write("==" & rsC("pbCategoryParentId") & "/"&rsC("pbCategoryId")) Dim fnClass fnClass = "" If rsC("pbDisplayBool") = "Hide" Then fnClass = "a1" End If Response.Write("├-  " & rsC("pbCategoryName") & "   
") Call ShowCategoryByParentId(rsC("pbCategoryId")) rsC.moveNext Loop Response.write("
") End If rsC.Close End Sub 'Call ShowCategoryByParentId(0) %> ============== 下来框中显示 树状结构 <% Sub ShowCategoryByParentId(varPid) Dim Countspace Countspace = Countspace + 1 Dim strSql,rsC strSql = "select * from vProCategory where pbCategoryParentId = " & varPid & " order by pbCategoryName" Set rsC=server.CreateObject("adodb.recordset") rsC.CursorLocation = 3 rsC.Open strSql,conn,3,3 If rsC.recordcount > 0 Then 'Response.write("
") Do until rsC.eof 'Response.Write("==" & rsC("pbCategoryParentId") & "/"&rsC("pbCategoryId")) Response.Write("") Call ShowCategoryByParentId(rsC("pbCategoryId")) rsC.moveNext Loop 'Response.write("
") End If rsC.Close End Sub Function ShowSpace(varNumb) Dim i,temp temp = "" 'For i=0 to varNumb 'temp = " " + temp 'Next ShowSpace = temp End Function %> =============== 下拉框中 选中 <% Sub ShowCategoryByParentId(varPid,rsPid) Dim strSql,rsC strSql = "select * from vProCategory where pbCategoryParentId = " & varPid & " order by pbCategoryName" Set rsC=server.CreateObject("adodb.recordset") rsC.CursorLocation = 3 rsC.Open strSql,conn,3,3 If rsC.recordcount > 0 Then Do until rsC.Eof Dim tempStr tempStr = "" If rsPid = rsC("pbCategoryId") Then tempStr = " selected" End If Response.Write("") Call ShowCategoryByParentId(rsC("pbCategoryId"),rsPid) rsC.moveNext Loop End If rsC.Close End Sub Sub GetLevel(varPid,inLevel,varSpace) Dim countNumb,rsA,sqA,i sqA = "select * from tProCategory where pbCategoryId =" & varPid Set rsA=server.CreateObject("adodb.recordset") rsA.CursorLocation = 3 rsA.Open sqA,conn,3,3 If rsA.Recordcount > 0 Then inLevel = inLevel + 1 call GetLevel(rsA("pbCategoryParentId"),inLevel,"") Else For i=0 to inLevel varSpace = varSpace + "  " Next varSpace = varSpace + "|-" Response.Write(varSpace) End If End Sub %>

你可能感兴趣的:(数据库,Css,ASP)