類似 MSDN 左邊導航樹效果的實現! [JavaScript + ASP] (轉)

worldblog發表於2007-12-15
類似 MSDN 左邊導航樹效果的實現! [JavaScript + ASP] (轉)[@more@]

MSDN 和CSDN 左邊導航樹的效果都是在點選父節點時,再發出請求填充其子節點!好像網頁只重新整理部分! script + [ +  Access] 實現

源:

<!-- Tree.asp --&gt



New Document










 
 
 

 

 
 
 
 
 

  dim adoConnection
  set adoConnection = Server.Create("ADO.Connection")
  'adoConnection.Open "Provr=OLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Test;Data =TRIATONPSQL2KE"
  adoConnection.Open "Provider=.Jet.OLEDB.4.0;Data Source=" & Server.mappath("/dvbbs") & "Tree.mdb;Persist Security Info=False"
  dim adoRecordset
  set adoRecordset = Server.CreateObject("ADODB.Recordset")
  adoRecordset.Open " *,(select count(*) from tree where parentid = T.id) as children from tree T where id = id ",adoConnection
  dim i
  i=0
  do until adoRecordset.eof
 %>


  adoRecordset.MoveNext
  l
  adoRecordset.close
  set adoRecordset = nothing
  adoConnection.close
  set adoConnection = nothing
%>
 

 

 



 

<!-- SubTree.asp --&gt



New Document






  dim parentid
  parentid = request.querystring("PID")
  parentnode = request.querystring("Parentnode")
  dim adoConnection
  set adoConnection = Server.CreateObject("ADODB.Connection")
'  adoConnection.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Test;Data Source=TRIATONPSQL2KE"

  adoConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.mappath("/dvbbs") & "Tree.mdb;Persist Security Info=False"
  dim adoRecordset
  set adoRecordset = Server.CreateObject("ADODB.Recordset")
  adoRecordset.Open "select *,(select count(*) from tree where parentid =T.id ) as Children from tree T where parentid = " & parentid ,adoConnection
  response.write  adoRecordset.source
  dim i
  Dim SHTML
  dim parentnode
  parentnode = request.querystring("Pnode")
  dim j
  j= len(parentnode) - len(replace(parentnode,"_",""))
  dim nSpace
  for i=0 to j - 1
  nSpace = nSpace + "  "
  next
  i=0
  do until adoRecordset.eof
  shtml = shtml _
  & "

"
  if adoRecordset.Fields.item("Children").value >0 then
  shtml = shtml & ""
  end if
  i=i+1
  adoRecordset.MoveNext
  loop
  adoRecordset.close
  set adoRecordset = nothing
  adoConnection.close
  set adoConnection = nothing
'response.write shtml
%>


表結構:
Tree(id,parentid,remark)

 

 


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752043/viewspace-993773/,如需轉載,請註明出處,否則將追究法律責任。

相關文章