My best guess is if you remove one item it changes the structure of the array and when it goes to remove the next one it cannot be found?
Use CFDump to display the array as you are looping over it to help debug. This way you can see the way the array is changing as you are removing items. > -----Original Message----- > From: jrmuniz [mailto:jrmu...@sfsailing.com] > Sent: Tuesday, January 12, 2010 4:16 PM > To: cf-talk > Subject: Problem deleting structure in an array > > > Hello: > > Sorry, I forgot the subject in my last post. > > I'm having an issue deleting a form structure that is in a shopping cart > array. > I'm sure it's something simple I'm doing wrong, but it's driving me crazy. > > I have a checkbox to select which items to delete. > If only one item is selected there is no error and it works fine. > If more than one item is selected then the error is triggered. > Strangely, if I resubmit the form after the error it works OK. > > If I select two items to delete the error is: > The error message is " Element at position [3] doesn't exist in > array" > > Here is the form code: > <cfloop from="1" to="#arrayLen(session.shoppingcart)#" index="i"> > <tr> > <td> > <cfinput type="checkbox" value="#i#" name="itemid#i#"> > </td> > <td> > <cfinput type="text" name="quantity#i#" > value="#session.shoppingcart[i].quantity#" size="3"> > </td> > <td> > <cfinput type="text" name="catalogno#i#" > value="#HTMLEditFormat(session.shoppingcart[i].catalog)#" size="10"> > </td> > <td> > <cfinput type="text" name="description#i#" > value="#HTMLEditFormat(session.shoppingcart[i].description)#" > size="40"></td> > <td> > <cfinput type="text" name="price#i#" > value="#session.shoppingcart[i].price#" size="3"> > </td> > </tr> > </cfloop> > > Here is the cfc code: > <cfloop from="1" to="#arrayLen(session.shoppingcart)#" index="i"> > > <cfif StructKeyExists(rc,"itemid" & i)> > <cfset private.temp = arrayDeleteAt(session.shoppingcart,i)> > </cfif> > </cfloop> > > Any help is greatly appreciated. > > Regards, > Jaime > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:329597 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4