Hi, I was wondering if anyone knows the code needed to update an element in an array. The element in the array is that of a quantity field. The code I have so far is as follows:
<CFLOOP index="rowCount" from="1" to="#ArrayLen(session.basket)#">
<CFOUTPUT>
<CFIF #rowCount# EQ #session.indexAnswer#>
<CFSET session.basket[ArrayLen(session.basket)][9]=form.quantity>
</CFIF>
</CFOUTPUT>
</CFLOOP>
I can find the proper element in the array to update and I am updating it with the form.quantity field but it is not updating the correct element just the last element in the array.
The session.indexAnswer is the arrays index be it 1,1 etc. I know by using the next line of code that this updates the last element's quantity field in the array. I know of an ArrayAppend and ArrayPrepend but these update the beginning and end of arrays? I haven't come across any others that seem to be what I am looking for?
Thanks.
<CFLOOP index="rowCount" from="1" to="#ArrayLen(session.basket)#">
<CFOUTPUT>
<CFIF #rowCount# EQ #session.indexAnswer#>
<CFSET session.basket[ArrayLen(session.basket)][9]=form.quantity>
</CFIF>
</CFOUTPUT>
</CFLOOP>
I can find the proper element in the array to update and I am updating it with the form.quantity field but it is not updating the correct element just the last element in the array.
The session.indexAnswer is the arrays index be it 1,1 etc. I know by using the next line of code that this updates the last element's quantity field in the array. I know of an ArrayAppend and ArrayPrepend but these update the beginning and end of arrays? I haven't come across any others that seem to be what I am looking for?
Thanks.