posted 17 years ago
Whenever you are dealing with the dynamic creation of tables in HTML or with dynamically modifying the data within them, you need to be aware of some quirks (some would say bugs) in the way that Microsoft Internet Explorer handles tables.
The most important of these quirks is that IE does not allow you to modify the contents of a <td> tag. So, if you have a table data tag with an id of, say, row1col1 and you tried to do the following:
it will not work in IE. It works fine in any of the Mozilla family of browsers. To get around this quirk, you need to create your table so that any data that you might ever want to change dynamically is in some other container, such as a <div>, which in turn is inside the <td>.
So, if we have:
We can then to the following in JavaScript:
This will work for all browsers (except maybe Opera).
Also, outputing the table with the JavaScript method "document.write(s)" is fine if you are building the complete document dynamically, but if you are trying to add to or modify an existing document, that is one that is currently being viewed on the browser by the user, "document.write(s)" will overwrite the existing document or portions of it.
If you are adding the table to an existing document, then have a <div> on the document so that you can add the table by adding to the division's innerHTML.
<a href="http://labryssystems.net/pblog/index.php" target="_blank" rel="nofollow">Javaville Gazette</a><br />Non-cooperation with evil is a duty. -- Mahatma Gandhi