View Full Version : Inserting text into a table cell via second cell
Hi. I'm new to this and need some expert help.
I have a table and I want to insert text into a specific cell from an external file when I hover over another cell.
How do I do this? (I said I was new to this!)
codeexploiter
04-09-2007, 10:43 AM
Are you looking for something like the following:
Please make sure that files 2.htm and 3.htm resides on the same folder where your mainfile.htm resides
mainfile.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Main File</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<table cellpadding="0" cellspacing="0" border="1" width="300">
<tr>
<td width="150"><iframe id="one" src="2.htm" frameborder="0" style="visibility:hidden;"></iframe></td>
<td width="150" ><iframe id="two" src="3.htm" frameborder="0" style="visibility:hidden;"></iframe></td>
</tr>
<tr>
<td width="150" onmouseover="document.getElementById('one').style.visibility='visible';" onmouseout="document.getElementById('one').style.visibility='hidden';"> </td>
<td width="150" onmouseover="document.getElementById('two').style.visibility='visible';" onmouseout="document.getElementById('two').style.visibility='hidden';"> </td>
</tr>
</table>
</body>
</html>
2.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
This is a testing by CodeExploiter
</body>
</html>
3.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
JavaScript is cool.
</body>
</html>
As this is just a demo I haven't inserted any meaningful information inside the above furnished pages.
Thanks for the quick reply and it'll do nicely. It seems odd that it's not possible to write directly to a cell without utilising a frame - but maybe I'm missing something.
boogyman
04-09-2007, 07:55 PM
you can, but css cannot do it. css has nothing to do with inserting data into a cell. css is used for presentation (color / structure).
mburt
04-09-2007, 07:58 PM
<script type="text/javascript">
var el = document.createElement("div");
el.appendChild(document.createTextNode("Hi, my name is new div tag."))
element.appendChild(el);
</script>
The DOM way of appending data.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.