<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> 动态增删表格 </TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
var i=1;
function addTable(content)
{
var categoryTable = document.getElementById("MyTable");
var newRow=categoryTable.insertRow(0);//如果从最后增加,insertRow不需要参数
var newCell=newRow.insertCell();
newCell.innerHTML=content+(i++);
}
function delTable()
{
var categoryTable = document.getElementById("MyTable");
if(categoryTable.rows.length>0){
categoryTable.deleteRow(0);//如果删除最后行,deleteRow不需要参数
}
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<table id="MyTable" border="0" cellpadding="0"></table>
<input type=Button onclick="addTable('NewRow ')" value="add">
<input type=Button onclick="delTable()" value="del">
</BODY>
</HTML>