While Working in one of my applications I had to create new row dynamically on click of a button.
The below code worked fine with Mozilla, however nothing happened in IE also no errors were shown
var theTable = document.getElementById(tableId);
var rowIdAttribute = i+1;
var newRow = document.createElement('tr');
newRow.setAttribute("id", rowIdAttribute); theTable.appendChild(newRow );
I found that IE does not support appendChild to add new rows in the table
So I added a container element to place the new row and append that container element.
Correct code is as shown below which works fine both in IE and Mozilla
var theTable = document.getElementById(tableId);
var newtbody = document.createElement('TBODY');
var rowIdAttribute = i+1;
var newRow = document.createElement('tr');
newRow.setAttribute("id", rowIdAttribute);
newtbody.appendChild(newRow);
theTable.appendChild(newtbody);
Thursday, April 19, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment