Once you use ArrayDeleteAt, the array is reindexed
try this :-)
<cfset idlist = "1,2,3" />
<cfset idlistsorted = ListSort(idlist) />
<cfloop from=1 to=ArrayLen(myarray) index=i >
<cfset IDtoDelete = ListGetAt(idlistsorted ,i) - i />
<cfset ArrayDeleteAt[IDtoDelete] />
</cfloop>
justin
-----Original Message-----
From: Bosky, Dave [mailto:[EMAIL PROTECTED]
Sent: 13 March 2003 16:38
To: CF-Talk
Subject: Arrays -Deleting specific items
I have an array and need to delete specific positions by using a list of
positions to delete.
Array contains 8 items and I need to delete the items at positions
"2,3,4,5,6".
I've been using the code below and it works most of the time if I delete one
at time but
once I try to delete multiple items it errors out. I'm obviously overlooking
something and
extra eyes would be great!
<CFSCRIPT>
INDEX_TO_DELETE = LISTSORT(form.INDEX_TO_DELETE,"NUMERIC","DESC");
FOR (INDEX=1;INDEX LTE ListLen(form.index_to_delete); INDEX=INDEX+1)
{
ArrayDeleteAt(session.aCart,ListGetAt(form.index_to_delete,index));
}
</CFSCRIPT>
Thanks,
Dave
HTC Disclaimer: The information contained in this message may be privileged
and confidential and protected from disclosure. If the reader of this
message is not the intended recipient, or an employee or agent responsible
for delivering this message to the intended recipient, you are hereby
notified that any dissemination, distribution or copying of this
communication is strictly prohibited. If you have received this
communication in error, please notify us immediately by replying to the
message and deleting it from your computer. Thank you.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4