<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>动态表单</title>
</head>
<body>
<script type="text/javascript">
var i=2;
function delrow()
{
row=event.srcElement.parentElement.parentElement.parentElement.rowIndex;
alert(row);
test.deleteRow(row);
}
function insert()
{
n=test.insertRow();
k=n.insertCell();
k.innerHTML="<div align='center'>用户"+i+":<input name='name"+i+"' type='text' size='20'></div>";
k=n.insertCell();
k.innerHTML="<div align='center'>密码"+i+":<input name='password"+i+"' type='text' size='20'></div>";
k=n.insertCell();
k.innerHTML="<div align='center'><input name='Del' type='button' value='删除' onClick='delrow()'></div>";
i++;
}
</script>
<form name="form1" method="post" action="">
<p> </p>
<table width="82%" border="1" align="center" cellpadding="2" cellspacing="5" bordercolor="#000000" id="test">
<tr>
<td width="40%">
<div align="center">用户1:
<input name="name1" type="text" size="20">
</div></td>
<td width="46%">
<div align="center">密码1:
<input name="password1" type="text" size="20">
</div></td>
<td width="14%"><div align="center">
<input name="Del" type="button" id="Del" value="删除" onClick="delrow()">
</div></td>
</tr>
</table>
<table width="50%" border="0" align="center" cellpadding="5">
<tr>
<td colspan="2"><div align="center">
<input name="Add" type="button" id="Add" value="增加" onClick="insert()">
<input type="submit" name="Submit" value="提交">
</div></td>
</tr>
</table>
</form>
</body>
</html>
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>动态表单</title>
</head>
<body>
<script type="text/javascript">
var i=2;
function delrow()
{
row=event.srcElement.parentElement.parentElement.parentElement.rowIndex;
alert(row);
test.deleteRow(row);
}
function insert()
{
n=test.insertRow();
k=n.insertCell();
k.innerHTML="<div align='center'>用户"+i+":<input name='name"+i+"' type='text' size='20'></div>";
k=n.insertCell();
k.innerHTML="<div align='center'>密码"+i+":<input name='password"+i+"' type='text' size='20'></div>";
k=n.insertCell();
k.innerHTML="<div align='center'><input name='Del' type='button' value='删除' onClick='delrow()'></div>";
i++;
}
</script>
<form name="form1" method="post" action="">
<p> </p>
<table width="82%" border="1" align="center" cellpadding="2" cellspacing="5" bordercolor="#000000" id="test">
<tr>
<td width="40%">
<div align="center">用户1:
<input name="name1" type="text" size="20">
</div></td>
<td width="46%">
<div align="center">密码1:
<input name="password1" type="text" size="20">
</div></td>
<td width="14%"><div align="center">
<input name="Del" type="button" id="Del" value="删除" onClick="delrow()">
</div></td>
</tr>
</table>
<table width="50%" border="0" align="center" cellpadding="5">
<tr>
<td colspan="2"><div align="center">
<input name="Add" type="button" id="Add" value="增加" onClick="insert()">
<input type="submit" name="Submit" value="提交">
</div></td>
</tr>
</table>
</form>
</body>
</html>