I have stumbled upon a program that creates javascript foldable menu in AsP.
I have tried unsucessfully to reproduce this code in CFML so I was wondering if someone on this forum would be able to do it.
My problem comes with the scripting technique used in ASP as opposed in ColdFusion. I was told that this is impossible to reproduce for CFML. Any opinions?
'procedure generates one node and recursively repeats for all children
sub DrawNode( Node )
dim rs, rsCildren
Dim NodeId, ParentID, Caption, Url, Target
'open node and read all fields to variables
set rs = dbConn.Execute("select * from dbo.treemenu where NodeID = " & Node )
NodeId = rs("NodeId"
ParentID = rs("ParentID"
Caption = QuoteAndCheckStr( rs("Caption" )
Url = QuoteAndCheckStr( rs("Url" )
Target = QuoteAndCheckStr( rs("Target" )
'write node to response
Response.Write(Space(Level * 4) & "[" & Caption & ", " & Url & ", " & Target)
rs.Close
set rs = nothing
'get all children
set rsCildren = dbConn.Execute("select * from dbo.treemenu where ParentID = " & Node )
if rsCildren.eof and rsCildren.bof then
'there is no children - close branch
Response.Write("]," & vbCrLf)
else
Level = Level + 1
Response.Write("," & vbCrLf)
'if children exists - call this sub recursively for each child
while not rsCildren.eof
call DrawNode( rsCildren("NodeId" )
rsCildren.MoveNext
wend
Level = Level - 1
Response.Write(Space(Level * 4) & "], " & vbCrLf)
end if
rsCildren.Close
set rsCildren = nothing
end sub
%>
I have tried unsucessfully to reproduce this code in CFML so I was wondering if someone on this forum would be able to do it.
My problem comes with the scripting technique used in ASP as opposed in ColdFusion. I was told that this is impossible to reproduce for CFML. Any opinions?
'procedure generates one node and recursively repeats for all children
sub DrawNode( Node )
dim rs, rsCildren
Dim NodeId, ParentID, Caption, Url, Target
'open node and read all fields to variables
set rs = dbConn.Execute("select * from dbo.treemenu where NodeID = " & Node )
NodeId = rs("NodeId"
ParentID = rs("ParentID"
Caption = QuoteAndCheckStr( rs("Caption" )
Url = QuoteAndCheckStr( rs("Url" )
Target = QuoteAndCheckStr( rs("Target" )
'write node to response
Response.Write(Space(Level * 4) & "[" & Caption & ", " & Url & ", " & Target)
rs.Close
set rs = nothing
'get all children
set rsCildren = dbConn.Execute("select * from dbo.treemenu where ParentID = " & Node )
if rsCildren.eof and rsCildren.bof then
'there is no children - close branch
Response.Write("]," & vbCrLf)
else
Level = Level + 1
Response.Write("," & vbCrLf)
'if children exists - call this sub recursively for each child
while not rsCildren.eof
call DrawNode( rsCildren("NodeId" )
rsCildren.MoveNext
wend
Level = Level - 1
Response.Write(Space(Level * 4) & "], " & vbCrLf)
end if
rsCildren.Close
set rsCildren = nothing
end sub
%>