realwx
02-04-2007, 01:01 AM
I'm trying to make a simple tree menu script to contract and expand certain tables & rows. However, it's telling me that it has an invalid ID specified. Here is what I'm doing:
<img src="collapse.gif" onclick="hideshow('pop',this);" style="cursor: hand; display: ''; float: right;" />
<tbody id="pop" style="display: block;">...table rows etc etc...</tbody>
function hideshow(id, imgthis) {
if(document.getElementById(id).style.display == "block" || document.getElementById(id).style.display == "") {
document.getElementById(id).style.display = "hidden";
imgthis.src="collapse_collapsed.gif";
} else if(document.getElementById(id).style.display == "hidden") {
document.getElementById(id).style.display = "";
imgthis.src="collapse.gif";
}
}
What am I doing wrong?
<img src="collapse.gif" onclick="hideshow('pop',this);" style="cursor: hand; display: ''; float: right;" />
<tbody id="pop" style="display: block;">...table rows etc etc...</tbody>
function hideshow(id, imgthis) {
if(document.getElementById(id).style.display == "block" || document.getElementById(id).style.display == "") {
document.getElementById(id).style.display = "hidden";
imgthis.src="collapse_collapsed.gif";
} else if(document.getElementById(id).style.display == "hidden") {
document.getElementById(id).style.display = "";
imgthis.src="collapse.gif";
}
}
What am I doing wrong?