<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function addTableFun()
{
var rowsSize = addTable.rows.length;
oTR=addTable.insertRow(addTable.rows.length);
oTR.style.background="#c1ebfc"
tmpNum=oTR.rowIndex;
oTD=oTR.insertCell(0);
oTD.align='center';
oTD.innerHTML=tmpNum;
oTD=oTR.insertCell(1);
oTD.align='center';
oTD.innerHTML="<input type='text' name='textfield' value='hhhhhhhhhhhh行'/>";
oTD=oTR.insertCell(2);
oTD.align='center';
oTD.innerHTML="<input type='button' name='Submit2' value='deleteRow' onclick='deleteTableFun(this)'/>";
}
function deleteTableFun(row)
{
var rowIndex = row.parentElement.parentElement.rowIndex;
var length = addTable.rows.length;
for(var i=length-1;i>rowIndex;i--)
{
addTable.rows[i].cells[0].innerText = i-1;
}
addTable.deleteRow(rowIndex);
}
</script>
</head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0" id="addTable">
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<input type="button" name="Submit" value="addRow" onclick="addTableFun()"/>
</body>
</html>
posted on 2007-09-05 11:12
梓枫 阅读(225)
评论(0) 编辑 收藏