vishnusanjit
12-08-2009, 01:58 PM
Hi All,
I'm trying to create a table on the page upon receiving an event from the user.
It works alright in Firefox but not in IE. There's no error message either in IE. Could someone shed some light on this? Here's the code:
<html>
<head>
<script type='text/javascript'>
function makeTable()
{
var nTable=document.createElement('table');
nTable.setAttribute('id','myTable');
nTable.setAttribute('border','1');
var nRow1=document.createElement('tr');
var nData11=document.createElement('td');
nData11.setAttribute('colspan','2');
var nCenter11=document.createElement('center');
var nBold=document.createElement('b');
nBold.appendChild(document.createTextNode('Title'));
nCenter11.appendChild(nBold);
nData11.appendChild(nCenter11);
nRow1.appendChild(nData11);
var nRow2=document.createElement('tr');
var nData21=document.createElement('td');
var nCenter21=document.createElement('center');
nCenter21.appendChild(document.createTextNode('21'));
nData21.appendChild(nCenter21);
var nData22=document.createElement('td');
var nCenter22=document.createElement('center');
nCenter22.appendChild(document.createTextNode('22'));
nData22.appendChild(nCenter22);
nRow2.appendChild(nData21);
nRow2.appendChild(nData22);
nTable.appendChild(nRow1);
nTable.appendChild(nRow2);
alert('Almost there !');
try
{
document.getElementById('container').appendChild(nTable);
}
catch (e)
{
alert(e.message);
}
return;
}
</script>
</head>
<body>
<div id='container'>
</div>
<br>
<input type=button value='Go' onclick='makeTable();'>
</body>
</html>
I'm trying to create a table on the page upon receiving an event from the user.
It works alright in Firefox but not in IE. There's no error message either in IE. Could someone shed some light on this? Here's the code:
<html>
<head>
<script type='text/javascript'>
function makeTable()
{
var nTable=document.createElement('table');
nTable.setAttribute('id','myTable');
nTable.setAttribute('border','1');
var nRow1=document.createElement('tr');
var nData11=document.createElement('td');
nData11.setAttribute('colspan','2');
var nCenter11=document.createElement('center');
var nBold=document.createElement('b');
nBold.appendChild(document.createTextNode('Title'));
nCenter11.appendChild(nBold);
nData11.appendChild(nCenter11);
nRow1.appendChild(nData11);
var nRow2=document.createElement('tr');
var nData21=document.createElement('td');
var nCenter21=document.createElement('center');
nCenter21.appendChild(document.createTextNode('21'));
nData21.appendChild(nCenter21);
var nData22=document.createElement('td');
var nCenter22=document.createElement('center');
nCenter22.appendChild(document.createTextNode('22'));
nData22.appendChild(nCenter22);
nRow2.appendChild(nData21);
nRow2.appendChild(nData22);
nTable.appendChild(nRow1);
nTable.appendChild(nRow2);
alert('Almost there !');
try
{
document.getElementById('container').appendChild(nTable);
}
catch (e)
{
alert(e.message);
}
return;
}
</script>
</head>
<body>
<div id='container'>
</div>
<br>
<input type=button value='Go' onclick='makeTable();'>
</body>
</html>