hide and show element doest not work on tables

Discussion in 'PHP' started by babyphp, May 6, 2008.

  1. #1
    just wodering if anyone can help me am using the hide and show elemnts for some reason it doesnt work when i put the hello world in a table but when there is no table it works

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Project Diary</title>
    <script type="text/javascript">

    window.onload = function() {

    dispHandle('vanisher');

    }

    function dispHandle(objId) {

    var obj = document.getElementById(objId);
    obj.style.display = (obj.style.display == 'none') ? 'block' : 'none';

    }

    </script>
    </head>
    <body>

    <p>
    <a href="#" onclick="dispHandle('vanisher')">Hide Show</a></p>
    <table width="200" border="1">
    <tr>
    <td>Hello World</td>
    </tr>
    </table>
    <p>&nbsp;</p>
    </body>
    </html>
     
    babyphp, May 6, 2008 IP
  2. apmsolutions

    apmsolutions Peon

    Messages:
    66
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Your table should look like this:

    <table width="200" border="1" id="vanisher>

    You need to apply the id to the table for it to work.
     
    apmsolutions, May 6, 2008 IP