Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Delete Single Variable from List

Participant ,
Jun 03, 2010 Jun 03, 2010

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>

2.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Jun 03, 2010 Jun 03, 2010

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

...
Translate
Engaged ,
Jun 03, 2010 Jun 03, 2010

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 04, 2010 Jun 04, 2010

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 04, 2010 Jun 04, 2010
LATEST

Sure thing--glad it worked out.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources