I have a working script that opens each table when clicked on. I want to have the tables open when the page loads for the first time. Currently the tables are hidden when the page loads for the first time. The script uses cookies to remember tables position. Can any help with this?
The current working script is below:
!--
function clickHandler() {
var targetId, srcElement, targetElement, srcId;
if (window.event) srcElement = window.event.srcElement;
else srcElement = clickHandler.arguments[0].target;
if (srcElement.className == "Outline") {
srcId = srcElement.id
if (srcElement.tagName.toLowerCase() == "img")
srcId = srcId.substr(0,srcElement.id.length-1);
targetId = srcId + "d";
if (document.getElementById) targetElement = document.getElementById(targetId);
else if (document.all) targetElement = document.all(targetId);
else return;
if (targetElement.style.display == "none") {
targetElement.style.display = "";
document.images(srcId + "i").src = "images/print.gif";
setCookie( targetId, "show" );
} else {
targetElement.style.display = "none";
document.images(srcId + "i").src = "images/print.gif";
setCookie( targetId, "none" );
}
}
}
function setCookie(name, value) {
document.cookie = name + "=" + escape(value);
}
function readtree() {
var dc = document.cookie;
if (dc.length > 0) {
ca = dc.split(";");
for ( c in ca ) {
mid = ca[c].indexOf("=");
if (ca[c].charAt(0) == " ") targetId = ca[c].substring(1,mid);
else targetId = ca[c].substring(0,mid);
if ( targetId.substr(0,3) != "Out") continue;
val = ca[c].substr(mid+1,4);
if (document.getElementById) targetElement = document.getElementById(targetId);
else if (document.all) targetElement = document.all(targetId);
else return;
if (val == "show") {
targetElement.style.display = "";
document.images(targetId.substr(0,targetId.length-1)+"i").src = "images/print.gif";
}
}
}
}
document.onclick = clickHandler;
//-->
</script>
------------------------------------------------------
<body onload="readtree();">
<div id="Out0d">
<dl>
<dt><span id="Out1" class="Outline" style="cursor: hand"><img src="images/print.gif" alt="print" width="19" height="18" hspace="4" class="Outline" id="Out1i" />WHAT EVER</span></dt>
<dd>
<div id="Out1d" style="display:None;">
<dl>
<dt><TABLE>
</TABLE>
</dt>
</dl>
</div>
</dd>
The current working script is below:
!--
function clickHandler() {
var targetId, srcElement, targetElement, srcId;
if (window.event) srcElement = window.event.srcElement;
else srcElement = clickHandler.arguments[0].target;
if (srcElement.className == "Outline") {
srcId = srcElement.id
if (srcElement.tagName.toLowerCase() == "img")
srcId = srcId.substr(0,srcElement.id.length-1);
targetId = srcId + "d";
if (document.getElementById) targetElement = document.getElementById(targetId);
else if (document.all) targetElement = document.all(targetId);
else return;
if (targetElement.style.display == "none") {
targetElement.style.display = "";
document.images(srcId + "i").src = "images/print.gif";
setCookie( targetId, "show" );
} else {
targetElement.style.display = "none";
document.images(srcId + "i").src = "images/print.gif";
setCookie( targetId, "none" );
}
}
}
function setCookie(name, value) {
document.cookie = name + "=" + escape(value);
}
function readtree() {
var dc = document.cookie;
if (dc.length > 0) {
ca = dc.split(";");
for ( c in ca ) {
mid = ca[c].indexOf("=");
if (ca[c].charAt(0) == " ") targetId = ca[c].substring(1,mid);
else targetId = ca[c].substring(0,mid);
if ( targetId.substr(0,3) != "Out") continue;
val = ca[c].substr(mid+1,4);
if (document.getElementById) targetElement = document.getElementById(targetId);
else if (document.all) targetElement = document.all(targetId);
else return;
if (val == "show") {
targetElement.style.display = "";
document.images(targetId.substr(0,targetId.length-1)+"i").src = "images/print.gif";
}
}
}
}
document.onclick = clickHandler;
//-->
</script>
------------------------------------------------------
<body onload="readtree();">
<div id="Out0d">
<dl>
<dt><span id="Out1" class="Outline" style="cursor: hand"><img src="images/print.gif" alt="print" width="19" height="18" hspace="4" class="Outline" id="Out1i" />WHAT EVER</span></dt>
<dd>
<div id="Out1d" style="display:None;">
<dl>
<dt><TABLE>
</TABLE>
</dt>
</dl>
</div>
</dd>