I have a form that will allow users to randomly select items to remove from
a form.  All of the items in the form are an Array of Structures.

By clicking "remove" the number of the array position is identified. More
than remove checkbox can be checked. They can be checked in any order.

Currently, if only one item is check and the submit button is clicked, the
item is removed from the Array without a problem.

The problem comes in when there is an attempt to remove two or more items
simultaneously.

An error such as this is displayed:

        "ArrayDeleteAt(Array, Position): Cannot delete element at position 7.
        The array has only 6 elements.

        "The error occurred while evaluating the expression:
        #ArrayDeleteAt(session.cart, i)#"

I've tried various ways to get this to work, so as sorting the array (which
didn't work because the first element isn't a simple variable), and trying
to get the cfloop to remove the bottom item before the top item.  That isn't
working.

Below is my current code, but my question is ... how can I loop through the
array and remove all of the items I want?

Current Code:


<cfoutput>#ListSort(form.remove, "numeric", "desc")#</cfoutput>

<cfloop index="i" list="#form.remove#">

        <cfoutput>
                #ArrayDeleteAt(session.cart, i)#
                #ArrayResize(session.cart, 1)#
        </cfoutput>

</cfloop>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to