I am trying to develop a simple shopping cart.
I have created an array of structures for this as 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 would like to delete a given entry in the array given a
particular FORM.id, say id = 220
Here is my code to try and delete the 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 is not working. I guess perhaps I should delete the
array entry, but I can't figure out how to do this. Thanks in
advance. -Noah