Results 1 to 4 of 4

Thread: How do make a table appear or disapear

  1. #1
    Join Date
    Mar 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How do make a table appear or disapear

    Im a bit lost, im looking for a way to make 3 different tables appear and disapear when you click on a link, whats the code?!?!?!?
    thanks in advance
    Martin

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Place this code between the head section of the page.

    Code:
    <script type="text/javascript">
    
    function showHide(id) {
    
      if (document.getElementById(id).style.display == "none") {
        document.getElementById(id).style.display = '';
      }
    
      else {
        document.getElementById(id).style.display = "none";
      }
    
    }
    </script>
    Then place this in the body of the page:

    Code:
    <a href="#" onclick="showHide('test1'); return false;">Hide Table 1</a>
    <a href="#" onclick="showHide('test2'); return false;">Hide Table 2</a>
    <a href="#" onclick="showHide('test3'); return false;">Hide Table 3</a>
    
    <table id="test1" border="1">
     <tr>
      <td>This is table 1</td>
     </tr>
    </table>
    
    <table id="test2" border="1">
     <tr>
      <td>This is table 2</td>
     </tr>
    </table>
    
    <table id="test3" border="1">
     <tr>
      <td>This is table 3</td>
     </tr>
    </table>
    Hope this helps.
    Last edited by thetestingsite; 03-23-2007 at 04:46 PM.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Mar 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Unfortunatly I pretty sure I fallowed these steps but its not work even we just the test copied directly, sorry about this bother, but I really appreciate the help

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    ok, I made some mistakes, and editted the above code. Should work now as I have tested it. Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

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
  •