Copy link to clipboard
Copied
Is this possible? I am trying to work on code I did not create and add a "remove" button for each of the items in a cart. The cart items are being passed as a list and then being looped over to display the contents of the cart in a form. Here is what I am working with:
<!---this is what happens when an item is added to the cart--->
<cfif isDefined("session.ezform") and session.ezform neq "">
<cfif not ListFind(session.ezform,url.id)>
<cfset session.ezform = ListAppend(session.ezform,url.id)>
</cfif>
<cfelse>
<cfif isDefined("url.id") and url.id neq "">
<cfset session.ezform = "#url.id#">
</cfif>
</cfif>
<!--I don't know what to put here once the remove button is clicked that will delete from the list where litm is equal to the list variable--->
<cfif IsDefined ("deleteprod")>
</cfif>
<!---the remove button link--->
<a href="ezform.cfm?deleteprod&litm=#litm#">Remove from Cart</a>
Have you looked at ColdFusion's handy ListDeleteAt() function?
http://livedocs.adobe.com/coldfusion/8/htmldocs/functions_l_08.html#130600
Used in conjuction with ListFindNoCase(), you can make short work of this:
<cfif isdefined("deleteprod")>
<!---Get position of listitem; returns 0 if no item is found--->
<cfset listpos = listfindnocase(mylist,url.litm)>
<cfif listpos neq 0>
<!---If listpos is not 0, we have a match; use listpost as the "position" of the item in the list we w
...Copy link to clipboard
Copied
Have you looked at ColdFusion's handy ListDeleteAt() function?
http://livedocs.adobe.com/coldfusion/8/htmldocs/functions_l_08.html#130600
Used in conjuction with ListFindNoCase(), you can make short work of this:
<cfif isdefined("deleteprod")>
<!---Get position of listitem; returns 0 if no item is found--->
<cfset listpos = listfindnocase(mylist,url.litm)>
<cfif listpos neq 0>
<!---If listpos is not 0, we have a match; use listpost as the "position" of the item in the list we want to delete--->
<cfset newlist = listdeleteat(oldlist,listpos)>
</cfif>
</cfif>
I haven't tested this, but it's probably on the right track.
Copy link to clipboard
Copied
Awesome! That worked exactly how I needed it to! I did read up a bit about ListDeleteAt() but I didn't really understand it. Thank you for doing that so I could read through it and understand how it works.
Copy link to clipboard
Copied
Sure thing--glad it worked out.