innner html thing mentioned in "goodies to go"

liunx

Guest
*** This question was submitted to our Mentor Community. The answer<br />
was provided by Taylor Smith.<br />
<br />
Q. I would like to know if it is possible to make an image open in a <br />
particular table of a cell from a link in another cell. Kind of like <br />
with <br />
frames where you tell it to open in a TARGET frame.<br />
<br />
A. If you give a cell a <span> with a name you can access it with <br />
cellname.innerHTML="New Stuff".<br />
For example<br />
<table><br />
<tr><br />
<td><a onclick="magiczone.innerHTML='Look here now!'">Click to change <br />
something.</a></td> <td><span name="magiczone">Pretty boring over <br />
here.</span></td> </tr> </table><br />
When someone clicks the link the text changes. You can use <span> like <br />
that <br />
anywhere in your files.<br />
<br />
<br />
All I get is a script error when I run it. On looking up InnerHTML on google, I get a whole bunch of conflicting stuff, involving everything from c# to shtml :P<br />
<br />
What's the deal there, has anyone else had issuse, does it need some other code piece that was missing?<br />
<br />
It sounds like a really useful bit of code if it worked :D<br />
<br />
cheers<br />
<br />
John<!--content--><td><a onclick="magiczone.innerHTML='Look here now!'">Click to change something.</a></td> <td><span name="magiczone">Pretty boring over here.</span></td><br />
More W3C DOM compliant:<br />
<br />
<td><a href=http://www.webdeveloper.com/forum/archive/index.php/"#" onclick="document.getElementById('magiczone').innerHTML='Look here now!';return false">Click to change something.</a></td> <td><span id="magiczone">Pretty boring over here.</span></td><br />
<br />
Don't expect it to work in NS 4.X or below.<!--content-->
 
Back
Top