Hi all,
I am dynamically creating a DIV within a newly added row to a previously created table. I'm stuck with the correct syntax. Below is my current effort:
Thanks in advance for any help!
I am dynamically creating a DIV within a newly added row to a previously created table. I'm stuck with the correct syntax. Below is my current effort:
Code:
function gradType(obj) {
insertDiv = document.createElement("div");
if (obj=="0") {
insertdiv = document.getElementById("insert");
while(insertDiv.firstChild)
{
insertDiv.removeChild(insertDiv.firstChild);
}
return;
} else if (obj=="1") {
//add row to table and populate with inputs
cnt++;
var table = document.getElementById("yourtable");
var rowCount = table.rows.length;
var addRow = table.insertRow(rowCount);
addRow.id = cnt-1;
var addCell = addRow.insertCell(0);
addCell.colSpan = 3;
addCell.innerHTML = '<div id="insert">Compund:<input name="Xcomp[]" id="alt" type="text"></div>';
addCell.appendChild(insertDiv);
return;
}
}
Comment