OK, codice modificato nella seguente maniera:
Ora però non compare nessuna voce nell'albero.codice:<HTML> <HEAD> <TITLE>MODULO RICERCA CONTENUTO CATALOGATO PER AREA</TITLE> <HTML> <HEAD> <SCRIPT LANGUAGE="JavaScript"> outline = new makeArray(40) // create global object function init(){ if (navigator.appName == "Netscape") { layerStyleRef="layer."; layerRef="document.layers"; styleSwitch=""; }else{ layerStyleRef="layer.style."; layerRef="document.all"; styleSwitch=".style"; } } function conferma(myform) { myform.submit(); } </SCRIPT> <SCRIPT LANGUAGE="JavaScript"> var caution = false function setCookie(name, value, expires, path, domain, secure) { var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "") if (!caution || (name + "=" + escape(value)).length <= 4000) document.cookie = curCookie else if (confirm("Cookie exceeds 4KB and will be cut!")) document.cookie = curCookie } function getCookie(name) { var prefix = name + "=" var cookieStartIndex = document.cookie.indexOf(prefix) if (cookieStartIndex == -1) return null var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length) if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex)) } function item(parent, text, depth) { this.parent = parent // is this item a parent? this.text = text // text for link (may include HTML) this.depth = depth // nested depth } function makeArray(length) { this.length = length // length of array (integer) } function makeDatabase() { outline[0] = new item(true, 'area funzionale', 0) outline[1] = new item(false, 'Servizi, 1) outline[2] = new item(false, 'Personale, 1) outline[3] = new item(false, 'Tecnica, 1) outline[4] = new item(false, 'Commerciale, 1) outline[5] = new item(false, 'Amministrativa, 1) outline[6] = new item(false, 'Qualita, 1) outline[7] = new item(false, 'Privacy, 1) setStates() setImages() } function setStates() { var storedValue = getCookie("outline") if (!storedValue) { for (var i = 0; i < outline.length; ++i) { if (outline[i].depth == 0) outline[i].state = true else outline[i].state = false } } else { for (var i = 0; i < outline.length; ++i) { if (storedValue.charAt(i) == '1') outline[i].state = true else outline[i].state = false } } } function setImages() { for (var i = 0; i < outline.length; ++i) { if (outline[i].state) if (outline[i].parent) // outline[i] is a parent if (outline[i + 1].state) // outline[i] is exploded outline[i].pic = '[img]/kmstatic-daw/ftv2folderopen.gif[/img] else // outline[i] is collapsed outline[i].pic = '[img]/kmstatic-daw/ftv2folderclosed.gif[/img] else // outline[i] is only a child (not a parent) outline[i].pic = '[img]/kmstatic-daw/ftv2doc.gif[/img] } } function toggle(num) { for (var i = num + 1; i < outline.length && outline[i].depth >= outline[num].depth + 1; ++i) { if (outline[i].depth == outline[num].depth + 1) outline[i].state = !outline[i].state // toggle state } setStorage() history.go(0) } function setStorage() { var text = "" for (var i = 0; i < outline.length; ++i) { text += (outline[i].state) ? "1" : "0" } setCookie("outline", text) } makeDatabase() </SCRIPT> </HEAD> <body BGCOLOR="#E5E1D3" link="#FF6200" vlink="#FF6200" alink="#FF6200" onLoad="init()"> <TABLE CELLPADDING=5 WIDTH="98%"> <TR> <TD> <SCRIPT LANGUAGE="JavaScript"> document.write('<PRE><H4>') for (var i = 0; i < outline.length; ++i) { alert(outline.length); if (outline[i].state) { for (var j = 0; j < outline[i].depth * 3; ++j) { document.write(' ') } document.write(outline[i].pic, ' ', outline[i].text, ' ') } else { var previous = i for (var k = i + 1; k < outline.length && outline[k].depth >= outline[previous].depth; ++k) { ++i } } } document.write('</H4></PRE>') </SCRIPT> </td> </tr> </TD> </TR> </TABLE> </BODY> </HTML> </BODY> </HTML>

 
			
			 
					
					
					
						 Rispondi quotando
  Rispondi quotando