我的页面上有这段代码。它通过单击按钮在一个表格行中创建一个复选框、下拉列表和文本框。我的问题是,当我单击保存按钮时,它不会保存创建的复选框、下拉列表和文本框,它只会保存页面上第一次显示的那个。函数 addRow(tableID) { var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var colCount = table.rows[0].cells.length;
for(var i=0; i<colCount; i++) {
var newcell = row.insertCell(i);
newcell.innerHTML = table.rows[0].cells[i].innerHTML;
//alert(newcell.childNodes);
switch(newcell.childNodes[0].type) {
case "text":
newcell.childNodes[0].value = "".id = "percent";
break;
case "checkbox":
newcell.childNodes[0].checked = false.id = "checkbox";
break;
case "create_select_box":
newcell.childNodes[0].selectedIndex = "0" .id = "percentage";
break;
}
}
}
function deleteRow(tableID) {
try {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
for(var i=0; i<rowCount; i++) {
var row = table.rows[i];
var chkbox = row.cells[0].childNodes[0];
if(null != chkbox && true == chkbox.checked) {
if(rowCount <= 1) {
alert("Cannot delete all the rows.");
break;
}
table.deleteRow(i);
rowCount--;
i--;
}
}
}catch(e) {
alert(e);
}
}