Insurance Quotes - Credit Cards - Debt Consolidation - Personal Loans - Tea Forums & Tea Industry Forum

PDA

View Full Version : dTree getElementById problem


tcardoso
May 19th 2008, 3:26 am
Hi,

I have a menu (kind of windows explorer), that I downloaded from
http://www.codigofonte.com.br/download.asp?arquivo=124
(still cannot use live links, sorry)

and on page just have to place

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Menu tree</title>
<link rel="StyleSheet" href="dtree.css" type="text/css" />
<script type="text/javascript" src="dtree.js"></script>
</head>
<body>
<div class="dtree">
<script type="text/javascript">
<!--
d = new dTree('d');
d.add(0,-1,'Meu Menu tree');
d.add(1,0,'Pata 1','#');
d.add(2,0,'Documento 2','#');
d.add(3,1,'Pasta 1.1','#');
d.add(4,0,'Documento 3','#');
d.add(5,3,'Pasta 1.1.1','#');
d.add(6,5,'Documento 1.1.1.1','#');
d.add(7,0,'Documento 4','#');
d.add(8,1,'Documento 1.2','#');
d.add(9,0,'Minhas Imagens','#','Pictures I\'ve taken over the years','','','imgfolder.gif');
d.add(10,9,'Viagem para o Sul','#','Pictures of Gullfoss and Geysir');
d.add(11,9,'Carros antigos','#');
d.add(12,0,'Lixeira','#','','','','trash.gif');
d.draw();
//-->
</script>
</div>
</body>
</html>


All working fine, the problem its that when I submit the page 2 or 3 times (and it rebuilds the menu) the select directory stop working:


this.s = function(id) {
cn = this.arrNodes[id];
if (this.selectedNode != id)
{
if (this.selectedNode)
{
alert("Objecto: "+this.instanceName);
alert("Selected: "+this.selectedNode);
eOldSpan = document.getElementById("s" + this.instanceName + this.selectedNode);
alert("eOldSpan: "+eOldSpan);
eOldSpan.className = "node";
}

eNewSpan = document.getElementById("s" + this.instanceName + id);
eNewSpan.className = "nodeSel";

this.selectedNode = id;
if (this.useCookies) this.setCookie('cs' + this.instanceName, cn.id);
}
}


this last alert("eOldSpan: "+eOldSpan); returns null.

Even if I leave my application and enter again it continue to return error, it only solves when I close the browser, so it must be something kept on cache.

Can anyone give me some help :)

Thanks
Telmo Cardoso

tcardoso
May 20th 2008, 2:20 am
no one? Not even a hint why something like that could happen?

Thanks