By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,652 Members | 1,484 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,652 IT Pros & Developers. It's quick & easy.

HELP: Problem setting style.display in NETSCAPE 6+

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.