急!多文本框问题
我在表单里用JS实现了用户可以自己增加输入某相值的文本框,但是在接收的时候我如何知道用户加了几个框,一共多少个框,怎么接收?怎么存储?我用ASP,代码如下
<script language="JavaScript">
function addRowToTable()
{
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()
{
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>
</form>