Unable to create a table in IE using Javascript.

N

noagbodjivictor

I don't know the problem with IE6. I have tried three methods, and
they all failed. I eliminated the use of mootools' framework in method
3. MooTools is not the problem. Because the table is created but is
not showing up. I have checked that with IE developper toolbar.

1st method

for(var i = 0; i < thelines.length; i++) {
var newrow = new Element('tr');
for(var j = 0; j < (posArray.length - 1); j++){
var newcol = new Element('td').appendText(result[j]);
newcol.injectInside(newrow);
}
newrow.injectInside($('result'));
}

2nd method

for(var i = 0; i < thelines.length; i++ )
{
var newrow = new Element('tr');
for(var j = 0; j < (posArray.length - 1); j++){
var newcol = new Element('td');
var txt = document.createTextNode(result[j]);
newcol.appendChild(txt);
newrow.appendChild(newcol);
}
$('result').appendChild(newrow);
}

3rd method

var oTable = document.createElement('table');
var oRow, oCell;
oTable.id = 'result';
for(var i = 0; i < thelines.length; i++ )
{
oRow = document.createElement('tr');
for(var j = 0; j < (posArray.length - 1); j++)
{
oCell = document.createElement('td');
oCell.innerText = result[j];
oCell.textContent = result[j];
oRow.appendChild(oCell);
}
oTable.appendChild(oRow);
}
oTableContainer = document.getElementById('tablecontainer');
oTableContainer.appendChild(oTable);
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]>,
First problem: you have posted code and you have not posted an URL
where we can examine all of the page code. Do not post code; post an
URL.

Dial-up users with off-line newsreaders won't like that at all. Others
may prefer not to go to strange URLs on anonymous advice.

Consensus is that problems should be reduced to the minimum code that
shows the problem (that often solves it) and posted here by
copy'n'paste. A URL in addition can be good, but not a URL instead.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
 

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

Forum statistics

Threads
473,767
Messages
2,569,573
Members
45,046
Latest member
Gavizuho

Latest Threads

Top