Hey, I've got some code to hide/show a comment box. However for some reason it will not work using 'document.getElementsById()'...
The JavaScript
Code:
function display(id){
var span = document.getElementsById(id);
for (i = 0; i < span.length; i++) {
if (span[i].style.display=='none'){
span[i].style.display='inline';
} else {
span[i].style.display='none';
}
}
}
The html on the page - I'm using a templating engine so hence ID will be different for every comment box on the page.
Code:
<p class="comment"><a href="#" onClick="JavaScript:display({docs.U_DOCID})">Make a comment</a> |
<a href="document.php?mode=view&d={docs.U_DOCID}">{docs.U_COMMENTS}</a></p>
<span style="display:none" id="{docs.U_DOCID}">
<!-- A FORM -->
</span>
The onCLick works if i change the JavaScript to byElementsByTag("span") but that affects all the spans, not just the one.
Any help?