Add table-row-cell in Internet Explorer

teammatt3's picture

He has: 2,102 posts

Joined: Sep 2003

Edit: http://www.webdeveloper.com/forum/showthread.php?t=191022. Need a tbody for IE.

What I'm doing is trying to add a table with a row and column to a div. Here's the JS. It works find in Firefox and Opera, but IE 6/7 it doesn't work.

function addElement()
{
var div = document.getElementById("live-answer");
var new_table = document.createElement("table");
var row = document.createElement("row");
var cell = document.createElement("td"); cell.align = "center";
var input = document.createElement("input"); input.type = "radio"; input.name = "correct";

cell.appendChild(input);
row.appendChild(cell);

new_table.appendChild(row);
div.appendChild(new_table);
}

Any ideas what it could be in Internet Explorer?

teammatt3's picture

He has: 2,102 posts

Joined: Sep 2003

And the radio button problem that follows can be solved with this little trick

They have: 2 posts

Joined: Oct 2008

In my little knowledge createElement work properly only in IMG and OPTION tag. It cann't create element like table,td in IE. If you want to create table,td you may try the following insertAdjacentHTML or so on...

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.