PDA

View Full Version : innerHTML problems


Robert Bell
03-21-2003, 11:53 AM
Hi

I'm having a problem with an innerHTML command.
Using ASP and JavaScript I have a DIV tag like below

<DIV ID="HideDept" STYLE="Visibility: Hidden">
<TABLE>
<tr>
<td><img src="btsubtract.gif"></td>
<td><b>Trust</b></td>
</tr>
</TABLE>
</DIV>

And this DIV tag

<DIV ID="ShowDept" STYLE="Visibility: Visible"></DIV>

As you can see the ShowDept is empty and Visible to the user. HideDept isn't visible and should never be seen by the user. The JavaScript function is shown below.

ShowDept.innerHTML = HideDept.innerHTML;

The contents from HideDept are displayed in the ShowDept layer but there is a side effect. It looks like the visibility of the HideDept changes to visible because further down the page from the ShowDept DIV the HideDept DIV contents are repeated.

I have checked and there are no other DIV's called ShowDept.

Can anyone help?

Roy Sinclair
03-21-2003, 03:37 PM
I put that into a simple page and it worked properly. Check the rest of your page, there's something else causing the duplication.


<html>
<head>
<title></title>
</head>
<body onload="ShowDept.innerHTML = HideDept.innerHTML;">
<DIV ID="HideDept" STYLE="Visibility: Hidden">
<TABLE>
<tr>
<td>
<img src="btsubtract.gif">
</td>
<td>
<b>
Trust
</b>
</td>
</tr>
</TABLE>
</DIV>
<hr />
<DIV ID="ShowDept">
</DIV>
</body>
</html>

eggman
03-21-2003, 05:41 PM
An alternative is to simply place HideDept offscreen with top or left set to -1000 or something like that. You won't have to worry if the visibility attribute of the style object is set or not.