Problem with IE. Please help.

R

Ralph

Hi

I have JS code to create table:

var oTableRows = null;
var oTableCols = null;
var iMainIntrCount = aMI.length/5;
var iTableRows = Math.ceil(iMainIntrCount/7);
var oMainIntrTable = document.getElementById('mainTopics');

for(var iRows=0; iRows < iTableRows; iRows++){
oTableRows = document.createElement('tr');
for(var iCols=0; iCols<7; iCols++){
oTableCols = document.createElement('td');
oTableCols.innerHTML = 'Sample Text';
oTableRows.appendChild(oTableCols);
}
oMainIntrTable.appendChild(oTableRows);
}

It works perfectly in FF but in IE i don't get anything. What do I do wrong?

Thank you for help.
 
V

VK

Ralph said:
It works perfectly in FF but in IE i don't get anything. What do I do wrong?

You should add rows not to table itself, but to tbody:

tableObject.tbodies[0].addRow(rowObject);
 
I

Ian Collins

Ralph said:
Hi

I have JS code to create table:

var oTableRows = null;
var oTableCols = null;
var iMainIntrCount = aMI.length/5;
var iTableRows = Math.ceil(iMainIntrCount/7);
var oMainIntrTable = document.getElementById('mainTopics');

for(var iRows=0; iRows < iTableRows; iRows++){
oTableRows = document.createElement('tr');
for(var iCols=0; iCols<7; iCols++){
oTableCols = document.createElement('td');
oTableCols.innerHTML = 'Sample Text';
oTableRows.appendChild(oTableCols);
}
oMainIntrTable.appendChild(oTableRows);
}

It works perfectly in FF but in IE i don't get anything. What do I do
wrong?

Thank you for help.

Prefer table (or thead/tbody).insertRow() and row.insertCell() methods
rather than appendChild. Less typing and table.insertRow() will create
and add to a tbody if the table does not have one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,241
Latest member
Lisa1997

Latest Threads

Top