ok...questo è lo script, messo in un include che viene poi richiamato dalla funzione CreaTree(Tree) che fisicamente me lo scrive su schermo...
<link rel="StyleSheet" href="tree.css" type="text/css">
<script type="text/javascript" src="tree.js"></script>
<script type="text/javascript">
<!--
var Tree = new Array;
// nodeId | parentNodeId | nodeName | nodeUrl
<%
query = "SELECT * FROM strutture ORDER BY id_struttura,sub_1,sub_2,sub_3,sub_4,sub_5"
set rs = server.CreateObject("ADODB.Recordset")
rs.Open query,Conn,3,3
if not rs.EOF then
count = 0
set dic = Server.CreateObject("Scripting.Dictionary")
dic.Add "livello0",0
dic.Add "livello1",0
dic.Add "livello2",0
dic.Add "livello3",0
dic.Add "livello4",0
dic.Add "livello5",0
livello=1
id = 0
oldId=0
do while not rs.EOF
id=id+1
if livello<=5 then
if rs("sub_" & livello)>0 then
dic("livello" & livello) = oldId
livello=livello+1
end if
end if
if livello>1 then
if rs("sub_" & (livello-1))=0 then
for i=livello-1 to 1 step -1
if rs("sub_" & i)=0 then
livello=i
end if
next
end if
end if
Response.Write "Tree[" & count & "] = """ & id & "|" & dic("livello" & (livello-1)) & "|" & Replace(rs("nome_struttura"),"'","\\'") & "|#;""" & vbCrlf
oldId=id
count = count + 1
rs.MoveNext
loop
end if
%>
//-->
</script>

Rispondi quotando