I am so <CF_CONFUSED> !!! I have created a shopping cart to add for the purchase of computer systems, and everything works ok if their is just one computer in the cart. I can update the quantity etc just fine. My problem comes in when I add another computer to the cart and then try to do an update of the quantity or delete it. When I hit update it looks like the items in the Array are switching places. IE : The sysModelNum is where the unitCost is suppose to be and so forth. I cannot figure it out. Do I need to loop over the items again on the update somehow to stop this from happening, and if so could someone give an example. I am posting portions of the code I am using to see if someone can see my error in logic. PLEASE HELLLLPPPPPP!!!!!!!!
This is the cart page after the form is submitted, it posts back to itself for update or delete <CFLOOP COLLECTION="#session.cart#" ITEM="i"> <CFOUTPUT> <FORM METHOD="post" ACTION="/index.cfm?fuseaction=showCart&sysModelNum=#session.cart[i] [1]#&#client.urltoken#" NAME="cart1"> <TABLE ALIGN="center" CELLPADDING="0" CELLSPACING="0" WIDTH="70%" BORDER="0"> <TR> <TD CLASS="header" width="31%">#session.cart[i][1]#</TD> <TD CLASS="header" width="13%">#dollarFormat(session.cart[i][2])#</TD> <TD CLASS="header" width="13%"><INPUT TYPE="text" NAME="qty" VALUE="#Trim(session.cart[i][3])#" SIZE="2" class="cart"></TD> <cfset total = (session.cart[i][2] * session.cart[i][3])> <TD CLASS="header" width="13%">#dollarFormat(total)#</TD> </TR> <TR> <INPUT TYPE="hidden" NAME="sysModelNum" VALUE="#session.cart[i][1]#"> <INPUT TYPE="hidden" NAME="show_price_top" VALUE="#session.cart[i][2]#"> <INPUT TYPE="hidden" NAME="cse" VALUE="#session.cart[i][4]#"> <INPUT TYPE="hidden" NAME="cpu" VALUE="#session.cart[i][5]#"> <INPUT TYPE="hidden" NAME="ram" VALUE="#session.cart[i][6]#"> <INPUT TYPE="hidden" NAME="hdd" VALUE="#session.cart[i][7]#"> <INPUT TYPE="hidden" NAME="sec_hdd" VALUE="#session.cart[i][8]#"> <INPUT TYPE="hidden" NAME="mtr" VALUE="#session.cart[i][9]#"> <INPUT TYPE="hidden" NAME="ctr" VALUE="#session.cart[i][10]#"> <INPUT TYPE="hidden" NAME="vid" VALUE="#session.cart[i][11]#"> <INPUT TYPE="hidden" NAME="snd" VALUE="#session.cart[i][12]#"> <INPUT TYPE="hidden" NAME="cdr" VALUE="#session.cart[i][13]#"> <INPUT TYPE="hidden" NAME="dvd" VALUE="#session.cart[i][14]#"> <INPUT TYPE="hidden" NAME="crw" VALUE="#session.cart[i][15]#"> <INPUT TYPE="hidden" NAME="modem" VALUE="#session.cart[i][16]#"> <INPUT TYPE="hidden" NAME="stg" VALUE="#session.cart[i][17]#"> <INPUT TYPE="hidden" NAME="spk" VALUE="#session.cart[i][18]#"> <INPUT TYPE="hidden" NAME="nic" VALUE="#session.cart[i][19]#"> <INPUT TYPE="hidden" NAME="clng" VALUE="#session.cart[i][20]#"> <INPUT TYPE="hidden" NAME="os" VALUE="#session.cart[i][21]#"> <INPUT TYPE="hidden" NAME="war" VALUE="#session.cart[i][22]#"> <TD><INPUT TYPE="submit" NAME="ACTION" value="Update"><INPUT TYPE="submit" NAME="ACTION" value="Delete"></TD> </TR> </TABLE> </CFOUTPUT> </CFLOOP> This is the struct that I created to hold the values of the computer system and handle the updates THIS IS CALLED AS A CUSTOM TAG IN THE ABOVE PAGE <CFSCRIPT> if (not(isDefined("session.cart"))){ session.cart = structNew(); } tempValue = listToArray( '#attributes.sysModelNum#, #attributes.price#, #attributes.qty#, #attributes.cse#, #attributes.cpu#, #attributes.ram#, #attributes.hdd#, #attributes.sec_hdd#, #attributes.mtr#, #attributes.ctr#, #attributes.vid#, #attributes.snd#, #attributes.cdr#, #attributes.dvd#, #attributes.crw#, #attributes.modem#, #attributes.stg#, #attributes.spk#, #attributes.nic#, #attributes.clng#, #attributes.os#, #attributes.war#' ); // Check to make sure that the item is in the cart, and if it is not add it. if (not(structKeyExists(session.cart,attributes.sysModelNum))) { structInsert(session.cart,attributes.sysModelNum,tempValue); } else { // If the item is already in the cart update the quantity tempvalue[3]=session.cart[attributes.sysModelNum][3]+attributes.qty; structUpdate(session.cart,attributes.sysModelNum,tempValue); } </CFSCRIPT> and this is the delete part THIS IS CALLED AS A CUSTOM TAG IN THE ABOVE PAGE <CFSCRIPT> if (isDefined("session.cart")){ if (StructKeyExists(session.cart, attributes.sysModelNum)) { structDelete(session.cart,attributes.sysModelNum); } } </CFSCRIPT> I hope someone can help <CF_SIGNATURE NAME="Douglas L. Brown" EMAIL="[EMAIL PROTECTED]" PHONE="714.538.6611" WEB="http://www.carnivorepc.com"> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Get the mailserver that powers this list at http://www.coolfusion.com FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists