Simple Shopping Cart


i trying develop simple shopping cart.
i have created array of structures follows.
<cfif not isdefined("session.shoppingcart")>
<cfset session.shoppingcart = arraynew(1)>
</cfif>

<cfset additem = structnew()>
<cfset additem.id = form.id>
<cfset additem.name = form.name>
<cfset additem.color = form.color>

<cfset arrayappend(session.shoppingcart, additem)>

i delete given entry in array given particular form.id, id = 220
here code try , delete item
<cfloop from="1" to="#arraylen(session.shoppingcart)#" index="i">
<cfif session.shoppingcart .id eq form.id>
<cfset foo = structdelete(session.shoppingcart
, id)>
<cfelse>
</cfif>
</cfloop>

this not working. guess perhaps should delete array entry, can't figure out how this. in advance. -noah

duh, figured out.
<cfset bar = arraydeleteat(session.shoppingcart, i)>
i having problem when looping not sure why. think because i'm deleting item in array tries loop index in array. "the element @ position 3 cannot found". guess wouldn't have delete multiple positions in array normal shopping cart unless selected 2 different id's. i'll work on more advanced shopping cart , post again.


More discussions in Advanced Techniques


adobe

Comments

Popular posts from this blog

Convierte tu Raspberry en un NAS. Firmware fvdw-sl 15.3 - Raspberry Pi Forums

How to format a Get Request

avrdude: verification error, first mismatch at byte 0x0000 0x0c != 0x62