Skip to main content
Known Participant
December 5, 2008
Question

Remove items from a list

  • December 5, 2008
  • 3 replies
  • 510 views
This isn't so much a cold fusion question as a just a logic question.
I have a form variable "form.list1" that contains numbers 1,2,3,4,5,6,7,8,9
I have a second form variable "form.list2" that contains numbers as well 3, 5, 6

What I want the end result to be is a variable that contains all of the numbers in form.list1 minus what is in form.list2, so that would be 1,2,4,7,8,9.
I can not for the life of me figure out how to do this.
I've tried doing a nested loop list, but I can't see the logic to make it work.

Any help would be greatly appreciated
    This topic has been closed for replies.

    3 replies

    Inspiring
    December 5, 2008
    > So the query outputs documents that need to be filled out by a user.
    > There is an option to email the documents to the user, but I have a
    > check box beside each one that will omit the checked document.

    I agree with Dan. Sounds like you could avoid the lists altogether by using a query. Just query the full document list and use NOT IN to exclude the checked items. The result should be only the documents to send.

    SELECT Whatever
    FROM YourDocumentTable
    WHERE DocumentID NOT IN
    (
    { list of checked item ids }
    )

    Inspiring
    December 5, 2008
    How were the lists generated? Maybe the problem can be avoided.

    Also, what were you going to do with the new list?
    cputnam14Author
    Known Participant
    December 5, 2008
    The first list is generated with an output query. The numbers represent a corresponding document type in my database.
    The second list is generated from a checkbox inside the output query.

    So the query outputs documents that need to be filled out by a user. There is an option to email the documents to the user, but I have a check box beside each one that will omit the checked document.

    The result is a list of all the documents, and a list of documents that don't need to be sent.

    With the resulting list, I will generate an email and attach the document to the email and send it out.
    cputnam14Author
    Known Participant
    December 5, 2008
    So I figured it out. Here is an example code of how I did it. This may not be the most efficient way, but it will work for my small list.

    Inspiring
    December 5, 2008
    Check www.cflib.org. I am certain they have a function for this, you can both use and review the code to understand how it is achieved.