HELP: Problem setting style.display in NETSCAPE 6+

S

Stewart

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>
 
I

Ivo

Stewart said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top