mackins60
February 15th, 2003, 11:57 AM
I have written an array (quantity data from a cookie) to form fields with a for loop e.g.
document.write('<td><input name="quant'+[i]+'" type="text" size="9" value="'+ ard[i] +'"></td>');
I want to allow users to change any of the quantity fields and when an 'Update Quantity' button or link is clicked, it executes a function that will read the form's quant[i] field values back into the quantity array, save to the cookie and then reload the page, which reads the updated cookie (quantity data) and writes the new quantity values back to the form fields along with it's calculations, totals etc.
Everything is working except I can't work out how to read the user changed quantity values back with a for loop from the quant[i] form fields.
for (i=0;i<arraylength;i++)
{
/* the next line is the one I'm having difficulty with!!!
I want to cycle through the form fields e.g. quant0, quant1,
quant2 etc. and overwrite the array values with all the quantity field values.*/
ard[i] = document.form1.quant+i+.value ;
What is the correct syntax for this line?
Thanks in advance,
Steve M
document.write('<td><input name="quant'+[i]+'" type="text" size="9" value="'+ ard[i] +'"></td>');
I want to allow users to change any of the quantity fields and when an 'Update Quantity' button or link is clicked, it executes a function that will read the form's quant[i] field values back into the quantity array, save to the cookie and then reload the page, which reads the updated cookie (quantity data) and writes the new quantity values back to the form fields along with it's calculations, totals etc.
Everything is working except I can't work out how to read the user changed quantity values back with a for loop from the quant[i] form fields.
for (i=0;i<arraylength;i++)
{
/* the next line is the one I'm having difficulty with!!!
I want to cycle through the form fields e.g. quant0, quant1,
quant2 etc. and overwrite the array values with all the quantity field values.*/
ard[i] = document.form1.quant+i+.value ;
What is the correct syntax for this line?
Thanks in advance,
Steve M