Forums
This topic is locked
ASP/Javascript multiple insert with form loop
Posted 14 Feb 2007 20:38:57
1
has voted
14 Feb 2007 20:38:57 Jean Marie posted:
I have an ASP page that inserts records to a database. In the form I have a dynamic loop where i is provided by a session variable. This works. However, if i=1 the record is inserted in the databasecorrectly but if i >1 then the insertRecord behavior tries to insert the input field i times in the associated table field.How can I insert all the input fields, row by row into the database, in sequence, when the submit button is presses?
Thank you for your help.
JM
=================
<script language="JavaScript" type="text/JavaScript">
var totalBoxes = <%= Session("sessNumberBoxes" %>;
var message = parseInt(totalBoxes );
for ( var i =1; i <= message; i++ )
{
document.write('<tr>');
document.write('<TD width="80" height="24" valign="top"> </TD>');
document.write('<TD width="50" valign="top"><input name="txtDetReceiverID" type="text" id="txtDetReceiverID" value="<%= Session("sessReceiverID" %>" size="10" maxlength="10"></TD>');
document.write('<TD width="30" valign="top"><input name="txtDetPO_LINE_NO" type="text" id="txtDetPO_LINE_NO" value="<%= Session("sessPO_LineNo" %>" size="3" maxlength="3"></TD>');
document.write('<TD width="70" valign="top"> </TD>');
document.write('<TD width="50" align="right" valign="top" NOWRAP><div align="right">Box #: </div></TD>');
document.write('<TD width="24" align="left" valign="top" size="3" maxlength="3"><div align="center"><input name="txtDetBoxNumber" type="text" id="txtDetBoxNumber" value="'+ i +'" size="3" maxlength="3"></div></TD>');
document.write('<TD width="40" align ="right" valign="top" NOWRAP>Qty: </TD>');
document.write('<TD width="40" align="left" valign="top"><input name="txtBoxQty" type="text" id="txtBoxQty" size="10" maxlength="10"></TD>');
document.write('</tr>');
}
</script>