View Full Version : hide and show information..

08-16-2007, 07:57 PM
Hey, im trying to hide some information on one of my page and then with javascript get it visible again. First I thought I could use the style "visibility:hidden;" but that will only remove the visibility and not the space the tag uses.
I could do it with ajax but I dont want any loading time and i already took the information out when i first loaded the page the first time.

I know how i can remove the td tag but im not sure how to show the info again because I would then remove the tag for good (until you reload the page of course)


found out that I can use:
style.display = 'none';

But if i load the javascript in the body onload function it will first show and then get removed, is it possible to have it hidden right away?

08-16-2007, 08:26 PM
This will open the page with the div hidden, then reveal it when you click the link:

<script type="text/javascript">
function toggleShow(item) {
var obj = document.getElementById(item);

if (obj.style.display == 'none') {
obj.style.display = 'block';

else if (obj.style.display == 'block') {
obj.style.display = 'none';

<a href="#" onclick="toggleShow('hidethis'); return false;">Show/Hide Div</a>

<div id="hidethis" style="display: none;">Now you see it, now you don't</div>

08-16-2007, 08:46 PM
Thanks, it works perfect now :)