<% 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 & "<br>") If rsC.recordcount > 0 Then Response.write("<div class='divShow'>") Do until rsC.eof 'Response.Write("==" & rsC("pbCategoryParentId") & "/"&rsC("pbCategoryId")) Dim fnClass fnClass = "" If rsC("pbDisplayBool") = "Hide" Then fnClass = "a1" End If Response.Write("├-<a class='"& fnClass &"' href="CategorysEdit.asp?pbCategoryId=" mce_href="CategorysEdit.asp?pbCategoryId=""& rsC("pbCategoryId") &"><img src="images/icon_edit.gif" mce_src="images/icon_edit.gif" width='15' height='15' border='0' title='Edit'> " & rsC("pbCategoryName") & " </a> <br>") Call ShowCategoryByParentId(rsC("pbCategoryId")) rsC.moveNext Loop Response.write("</div>") End If rsC.Close End Sub 'Call ShowCategoryByParentId(0) %> ============== 下来框中显示 树状结构 <select name="pbCategoryParentId" id="pbCategoryParentId"> <option value="0"> * Top</option> <% call ShowCategoryByParentId(0)%> </select> <% 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("<div class='divShow'>") Do until rsC.eof 'Response.Write("==" & rsC("pbCategoryParentId") & "/"&rsC("pbCategoryId")) Response.Write("<option value='" & rsC("pbCategoryId") &"'>" & ShowSpace(Countspace) &rsC("pbCategoryName") & "</option>") Call ShowCategoryByParentId(rsC("pbCategoryId")) rsC.moveNext Loop 'Response.write("</div>") 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("<option value='" & rsC("pbCategoryId") &"'" & tempStr &">" ) Call GetLevel(rsC("pbCategoryParentId"),0,"") Response.Write(rsC("pbCategoryName") & "</option>") 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 %> <select name="pbCategoryParentId" id="pbCategoryParentId"> <option value="0" <% If rsRecord_ById("pbCategoryParentId") = 0 Then Response.Write(" selected") End If %> > |-TopLevel</option> <% call ShowCategoryByParentId(0,rsRecord_ById("pbCategoryParentId"))%> </select>