<html>
<head>
<title>自动添加一行或删除一行</title>
</head>
<script>
var rowid=3;
function insertRow(){
newRow=PLList.insertRow(PLList.rows.length);
newRow.id="tdt";
newRow.bgColor="#e0e0e0";
newRow.className="tableData";
c1=newRow.insertCell(0);
c1.id="delItem";
c1.className="scheduleButtonVisible";
c1.innerHTML="<input type=text name=PLID value=0>";
c2=newRow.insertCell(1);
c2.innerHTML="<input type=text size=10 maxlength=10 name=date class=tableData >";
c3=newRow.insertCell(2);
c3.innerHTML="<input type=text size=10 maxlength=10 name=date1 class=tableData >";
}
//删除最后1行
function DeleteRow(tableId)
{ var objTable = document.getElementById(tableId);
if(objTable.rows.length==1)
{ alert("对不起,你不能删除表格头!!!");
return; }
if(confirm("确定删除?"))
{ objTable.deleteRow(); }
}
</script>
<body>
<table><tr><td>
<table id=PLList><tr><td>aa</td><td>bb</td><td>cc</td></tr></table>
</td></tr></table>
<input type="button" value="addRow" onclick="insertRow()">
<input type="button" onClick="DeleteRow('PLList')" value="删除一行">
</body>
</html>
<head>
<title>自动添加一行或删除一行</title>
</head>
<script>
var rowid=3;
function insertRow(){
newRow=PLList.insertRow(PLList.rows.length);
newRow.id="tdt";
newRow.bgColor="#e0e0e0";
newRow.className="tableData";
c1=newRow.insertCell(0);
c1.id="delItem";
c1.className="scheduleButtonVisible";
c1.innerHTML="<input type=text name=PLID value=0>";
c2=newRow.insertCell(1);
c2.innerHTML="<input type=text size=10 maxlength=10 name=date class=tableData >";
c3=newRow.insertCell(2);
c3.innerHTML="<input type=text size=10 maxlength=10 name=date1 class=tableData >";
}
//删除最后1行
function DeleteRow(tableId)
{ var objTable = document.getElementById(tableId);
if(objTable.rows.length==1)
{ alert("对不起,你不能删除表格头!!!");
return; }
if(confirm("确定删除?"))
{ objTable.deleteRow(); }
}
</script>
<body>
<table><tr><td>
<table id=PLList><tr><td>aa</td><td>bb</td><td>cc</td></tr></table>
</td></tr></table>
<input type="button" value="addRow" onclick="insertRow()">
<input type="button" onClick="DeleteRow('PLList')" value="删除一行">
</body>
</html>