%@ Language=VBScript %> <% option explicit Response.Expires=-1 %> <% Dim databaseDir, Conn 'Change this to a path (c:\...) if the database is not in the same dir of the 'current file databaseDir = Server.MapPath("demoDynamic.mdb") Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & databaseDir) ' This is a recursive function; it will find the children directly under ' a node and then call itself for each of those children in order to find ' the grand-children. For each entry in the DB that this function finds, ' it sends a snippet of JavaScript to the browser with the Treeview ' commands necessary for the construction of a node (either a folder or ' a doc). ' ' conn: is an ADODB.Connection opened on a database with a table ' called NodesTable ' parentId: is the value of the ParentID field for a record in the ' database ' parentObject: is the name of the JavaScript variable used to define ' the parent sub outputJavascriptForRoot(Conn) dim rsHits, queryString queryString = "SELECT NodeID, NodeName, IsFolder, ParentID, Link FROM NodesTable WHERE (ParentID=-1)" Set rsHits = Server.CreateObject("ADODB.Recordset") rsHits.Open queryString, Conn outputJavascriptForSubFolder Conn, rsHits("NodeID"), rsHits("NodeName"), "fSub1" response.write "foldersTree = fSub1" end sub sub outputJavascriptForSubFolder(Conn, folderId, nodeName, fName) dim rsHits, queryString, gFldStr, gLnkStr, fi, subFolders, di queryString = "SELECT NodeID, NodeName, IsFolder, ParentID, Link FROM NodesTable WHERE ((ParentID=" & folderId & ") AND (IsFolder=True)) ORDER BY NodeName" Set rsHits = Server.CreateObject("ADODB.Recordset") rsHits.Open queryString, Conn fi=1 do while not rsHits.EOF outputJavascriptForSubFolder Conn, rsHits("NodeID"), rsHits("NodeName"), fName & "Sub" & fi rsHits.MoveNext fi=fi+1 loop response.write fName & " = " & "gFld('" & nodeName & "', 'javascript:parent.op();')" & VbCrLf response.write fName & ".xID = " & folderId & VbCrLf ' Call the addChildren function response.write fName & ".addChildren([" ' member of the list argument to addChildren if not rsHits.BOF then rsHits.MoveFirst() fi=1 do while not rsHits.EOF if fi>1 then response.write ", " response.write fName & "Sub" & fi rsHits.MoveNext fi=fi+1 loop rsHits.close subFolders = fi-1 'Count how many queryString = "SELECT NodeID, NodeName, Link FROM NodesTable WHERE ((ParentID=" & folderId & ") AND (IsFolder=False)) ORDER BY NodeName" rsHits.Open queryString, Conn di = 1 do while not rsHits.EOF if di>1 or subFolders > 0 then response.write ", " response.write "['" & rsHits("NodeName") & "', '" & rsHits("Link") &"']" rsHits.MoveNext di = di + 1 loop response.write "])" & VbCrLf 'Close addChildren function ' xID's for docs if not rsHits.BOF then rsHits.MoveFirst() di = subFolders do while not rsHits.EOF response.write fName & ".children[" & di & "].xID = " & rsHits("NodeID") & VbCrLf rsHits.MoveNext di = di+1 loop rsHits.close end sub %>