Results 1 to 3 of 3

Thread: hide and show information..

  1. #1
    Join Date
    Aug 2006
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default hide and show information..

    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)

    edit:

    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?
    Last edited by Dennis_Gull; 08-16-2007 at 08:05 PM.

  2. #2
    Join Date
    Feb 2007
    Posts
    293
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This will open the page with the div hidden, then reveal it when you click the link:
    Code:
    <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';
       }
    }
    </script>
    
    <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>

  3. #3
    Join Date
    Aug 2006
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks, it works perfect now

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •