470,572 Members | 2,093 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,572 developers. It's quick & easy.

HELP: Problem setting style.display in NETSCAPE 6+

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>
Jul 23 '05 #1
2 1740
Ivo
"Stewart" <wi**************@yahoo.com.au> wrote in message
news:3e**************************@posting.google.c om...
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

Jul 23 '05 #2
DU
Stewart wrote:
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>

Your markup code is certainly not valid here. A block-level (table)
element can not be nested in an inline (span) element.
Also, I suspect you're using tables to render non-tabular data. So why
not solve your real problem to begin with? You should not use, you don't
need to use table to render text content to begin with.

DU
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Chris Beall | last post: by
20 posts views Thread by Jeff Nibler | last post: by
3 posts views Thread by Iver Erling Årva | last post: by
3 posts views Thread by Fabian | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.