HELP: Problem setting style.display in NETSCAPE 6+

Discussion in 'Javascript' started by Stewart, May 21, 2004.

  1. Stewart

    Stewart Guest

    Hi Experts.

    Please put the code sample below into an html document and take a look
    at in NN6+. One span should be shown while the other is hidden.
    Clicking the button should reverse this. However it doesn't.
    Removing the table structure from around the text fixes it, but I need
    the table structure (this is very simplified example).

    Hope someone can provide an alternative?

    Thanks,

    Stewart

    <html>
    <head>
    <title>Spans</title>
    <script type="text/javascript">
    function hideShow()
    {
    var spn1 = document.getElementById("spnShow");
    var spn2 = document.getElementById("spnHide");
    if (spn1.style.display == "inline")
    {
    spn1.style.display = "none";
    spn2.style.display = "inline";
    }
    else
    {
    spn1.style.display = "inline";
    spn2.style.display = "none";
    }

    }
    </script>
    </head>

    <body bgcolor="#FFFFFF">
    <input type="button" value="Hide/Show" onclick="hideShow();">
    <span id="spnShow" style="display: inline"><table><tr><td>Why can't I
    be hidden?</td></tr></table></span>
    <span id="spnHide" style="display: none"><table><tr><td>I should not
    be visible</td></tr></table></span>
    </body>
    </html>
     
    Stewart, May 21, 2004
    #1
    1. Advertising

  2. Stewart

    Ivo Guest

    Re: Problem setting style.display in NETSCAPE 6+

    "Stewart" <> wrote in message
    news:...
    > Hi Experts.
    >
    > Please put the code sample below into an html document and take a look
    > at in NN6+. One span should be shown while the other is hidden.
    > Clicking the button should reverse this. However it doesn't.
    > Removing the table structure from around the text fixes it, but I need
    > the table structure (this is very simplified example).
    >
    > <span id="spnShow" style="display: inline"><table><tr><td>Why can't I
    > be hidden?</td></tr></table></span>
    > <snip rest>


    Your function looks fine but why not toggle the display of the table itself?
    <table id="tblShow">...

    HTH
    Ivo
     
    Ivo, May 21, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Toby Mills
    Replies:
    0
    Views:
    1,591
    Toby Mills
    Jun 24, 2003
  2. Tom
    Replies:
    0
    Views:
    506
  3. Mickey Segal
    Replies:
    1
    Views:
    675
    Mickey Segal
    May 21, 2004
  4. Ken Varn
    Replies:
    0
    Views:
    496
    Ken Varn
    Apr 26, 2004
  5. yaktipper
    Replies:
    10
    Views:
    289
    Richard Cornford
    Jul 10, 2003
Loading...

Share This Page