用隐藏的input控件保存框的数目,提交时接收------------------------------------------------
www.cndigs.com掘客园--发掘、推荐软件开发资源,分享、交流技术开发心得
asp.net2.0资料
http://www.cndigs.com/search.php?search=asp.net%202.0&tag=true
asp.net资料
http://www.cndigs.com/search.php?search=asp.net&tag=true
ajax资料
http://www.cndigs.com/search.php?search=ajax&tag=true
www.cndigs.com掘客园--发掘、推荐软件开发资源,分享、交流技术开发心得
asp.net2.0资料
http://www.cndigs.com/search.php?search=asp.net%202.0&tag=true
asp.net资料
http://www.cndigs.com/search.php?search=asp.net&tag=true
ajax资料
http://www.cndigs.com/search.php?search=ajax&tag=true
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
var i = 0;
function addNum()
{
i++;
document.all.textBoxNum.value = i;
}function subNum()
{
i--;
document.all.textBoxNum.value = i;
}</script>
</head><body>
<form id="form1" name="form1" method="post" action="">
<label>
<input type="hidden" name="textBoxNum" />
<input type="button" name="add" value="增加" onclick="javascript:addNum()" />
<input type="button" name="sub" value="减少" onclick="javascript:subNum()" />
</label>
</form>
</body>
</html>我说的就是这个意思,在服务器端你用Request接收这个文本框的值就可以了
------------------------------------------------
www.cndigs.com掘客园--发掘、推荐软件开发资源,分享、交流技术开发心得
asp.net2.0资料
http://www.cndigs.com/search.php?search=asp.net%202.0&tag=true
asp.net资料
http://www.cndigs.com/search.php?search=asp.net&tag=true
ajax资料
http://www.cndigs.com/search.php?search=ajax&tag=true
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<script language="JavaScript">
var i = 1;function addRowToTable()
{i++;
document.all.textBoxNum.value = i;var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
var iteration = lastRow;
var row = tbl.insertRow(lastRow);var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellLeft.appendChild(textNode);var cellRight = row.insertCell(1);
var el = document.createElement('input');
el.setAttribute('type', 'text');
el.setAttribute('name', 'txtRow' + iteration);
el.setAttribute('size', '40');
cellRight.appendChild(el);
}
function removeRowFromTable()
{i--;
document.all.textBoxNum.value = i;var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
if (lastRow > 2) tbl.deleteRow(lastRow - 1);
}
</script>
<form action="tableaddrow_nw.html" method="get"><input type="button" value="Add" onclick="addRowToTable();" />
<input type="button" value="Remove" onclick="removeRowFromTable();" />
<table border="1" id="tblSample">
<tr>
<th colspan="2">Sample table</th>
</tr>
<tr>
<td>1</td>
<td><input type="text" name="txtRow1" size="40" /></td>
</tr>
</table>
<input type="hidden" name="textBoxNum" /></form>
</body>
</html>
------------------------------------------------
www.cndigs.com掘客园--发掘、推荐软件开发资源,分享、交流技术开发心得
asp.net2.0资料
http://www.cndigs.com/search.php?search=asp.net%202.0&tag=true
asp.net资料
http://www.cndigs.com/search.php?search=asp.net&tag=true
ajax资料
http://www.cndigs.com/search.php?search=ajax&tag=true