homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Gold Sponsor 2015!
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Problems with javascript tables in Mozilla

Msg#: 4429634 posted 5:10 pm on Mar 15, 2012 (gmt 0)

I am having poblems trying and modifying an HTML table from javascript with Mozilla, not with IE.
I have an html table where each row is identifyed by an id like this:

<tr id="row">

the table has n rows and m columns. From javascript I try and modify any cell in the table like this:


where i is the cell row and j is the cell column. I would like to set the cell to value.

Mozilla does not change the cell, while in IE I do get the cell changed.

Anybody can help?



WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

Msg#: 4429634 posted 5:30 pm on Mar 15, 2012 (gmt 0)

Welcome to WebmasterWorld.
Since you seem be accessing the rows and columns by index, I don't see how the row id applies in your example. You haven't really provided enough useful code.

Here's a quick example I put together which may be of help to you:

<!DOCTYPE html>
<table id="myTable">
<td>Row 1, Col 1</td>
<td>Row 1, Col 2</td>
<td>Row 2, Col 1</td>
<td>Row 2, Col 2</td>
var i,
table = document.getElementById('myTable'),
rows = table.getElementsByTagName('tr'),
// Iterate over each row
for (i = 0; i < rows.length; i++) {
// For each row, get the list of cells
cells = rows[i].getElementsByTagName('td');
// Iterate over the list of cells
for (j = 0; j < cells.length; j++) {
// Assign a new value to each cell
// For this example, I'm just prepending [i, j] (where i = row and j = col)
cells[j].innerHTML = "[" + i + ", " + j + "] " + cells[j].innerHTML;


Msg#: 4429634 posted 8:35 am on Mar 16, 2012 (gmt 0)

It works both in Mozilla and IE, thanks a lot for your help!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved