[Javascript] How to make IE display changes to DOM tree?

Peter Brunone peter at brunone.com
Sun Dec 12 22:33:47 CST 2004


Hi Matt,

	I tried your script and it didn't work for me either.  For what
it's worth, when I want to add table rows in IE, I use the insertRow()
and insertCell() methods of the table and tr, respectively.  You can
read up on them at the MSDN site:

http://tinyurl.com/52nbl

Cheers,

Peter Brunone
___________________
www.EasyListBox.com


-----Original Message-----
From: javascript-bounces at LaTech.edu On Behalf Of Matthew Palmer

Trying to make a page dynamically add extra rows (form fields, actually)
to a page.  Works wonderfully in Mozilla, refuses to do the trick in IE.

Minimalistic example:

----8<---
<html>
<head>
<script language="JavaScript">
function appendRow()
{
	tbl = document.getElementById('DynamicTable');
	newrow = document.createElement('TR');
	newcell = document.createElement('TD');
	text = document.createTextNode('Foo');
	newcell.appendChild(text);
	newrow.appendChild(newcell);
	newcell = document.createElement('TD');
	text = document.createTextNode('Bling');
	newcell.appendChild(text);
	newrow.appendChild(newcell);

	tbl.appendChild(newrow);
}
</script>
</head>
<body>
<h1>Foo</h1>

<button onClick="appendRow()">Click me!</button>

<table name="DynamicTable" id="DynamicTable" border="1">
	<tr>
		<td>Here</td>
		<td>There</td>
	</tr>
</table>

</body>
</html>
---->8----

Does the sensible thing in Mozilla Firefox (appends a new table row for
each click), but IE doesn't show any change.  Weirdest thing is, if you
do a tree dump of the DOM from the root of the table, the new nodes
*are* in there -- they just never get displayed.

I'm not clueful enough to check if the newly created nodes are somehow
"display: hidden" or something, but since no example out there in the
real world shows code for unmasking these phantom elements, I don't
think that's the problem.

Can someone at least cut-n-paste the example above into a browser and
tell me if it works for them?  I'm using IE 6.0.2800.1106 on Windows 98
to test. 
I've tried jacking the security zone to the most trusted level, but I
still can't get it to work.

All help greatly appreciated, preferably before I tear *all* my hair
out,

- Matt

-- 
[On LDAP] "Lightweight my ass.  The fact that X.509 has the weight of an
18-wheel rig doesn't make a minivan something you shove in your
backpack."
		-- Zed Pobre, ASR





More information about the Javascript mailing list