<html xmlns="
http://www.w3.org/1999/xhtml" lang="zh-CN">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="Content-Language" content="zh-CN" />
<meta content="all" name="robots" />
<html>
<head>
<title>test</title>
</head>
<script language="javascript" type="text/javascript">
function deleteCurrentRow()//刪除當前行
{
var currRowIndex=event.srcElement.parentNode.parentNode.rowIndex;
document.all.table10.deleteRow(currRowIndex);//table10--表格id
}
function insertRow()
{
var nRow=document.all.table10.rows.length; //表格的總行數
var objTheRow=document.all.table10.insertRow(nRow);//在最下邊新增一行
objTheRow.insertCell(0);//新增一個單元格
objTheRow.insertCell(1);
objTheRow.insertCell(2);
objTheRow.insertCell(3);
objTheRow.insertCell(4);
objTheRow.cells(0).innerHTML="<td><input type="text" name="textfield" width="50"></td>";//對新增的單元格?容
objTheRow.cells(1).innerHTML="<td><input type="text" name="textfield2" width="60"></td>";
objTheRow.cells(2).innerHTML="<td><input type="text" name="textfield3" width="60"></td>";
objTheRow.cells(3).innerHTML="<td><input type="text" name="" width="60"></td>";
objTheRow.cells(4).innerHTML="<td><button onClick="deleteCurrentRow()">删除</button></td>";
}
</script>
<body>
<table width="494" border="1" align="center" id="table10">
<tr>
<td width="88">姓名</td>
<td width="102">密码</td>
<td width="93">生日</td>
<td width="90">职业</td>
<td width="87"><button type="button" name="aa" value="bb" onClick="insertRow()">增加</button></td>
</tr>
<tr>
<td><input type="text" name="textfield" width="50"></td>
<td><input type="text" name="textfield2" width="60"></td>
<td><input type="text" name="textfield3" width="60"></td>
<td><input type="text" name="" width="60"></td>
<td><button onClick="deleteCurrentRow()">删除</button></td>
</tr>
</table>
</body>
</html>