Yup, you are close.

First get your list, which you've done
<cfset ImageList = ValueList(testSQL.contactID)>

Then pick a random position. I believe this is where your problem is.
Say the list has 10 items in it. You want to pick a random number between 1
and 10 versus the values of the items in the list. 

If your list had 9,5,8,34,6,1,14,73 in it, your cfset would look like
RandRange(9, 73) there are a lot of numbers between 9 and 73 and none of
them are positions in the list of 8 (which is how long that list is) items.
Does that make sense?

Any how, you want a position between 1 and the number of items so use
listlen()

<cfset RandomPosition = RandRange(1, ListLen(ImageList))>

I think you have the rest figured out but here goes anyhow...

Next get the ID at the random position
<cfset NewImageID = ListGetAt(ImageList, RandomPosition)>

Last, take the id out of the list using the randomposition variable
<cfset NewImageList = ListDeleteAt(ImageList, RandomPosition)>

Of course the whole thing will bomb if there are less than 2 items in the
list but you can wrap it all in a check if need be.

Hope it helps. Good luck


-----Original Message-----
From: Phillip Perry [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 20, 2004 6:14 PM
To: CF-Talk
Subject: Subtracting From a List

OK I wrote this email 10 times trying to word it right. All I want to know
is how to delete an ImageID from the list after it is displayed on the
browser using the following variables.

<cfset ImageList = "#ValueList(testSQL.contactID)#"/>
<cfset MaxListLen = #ListLen(ImageList)#>
<cfset ListRandImage =
"#RandRange(ListFirst(ImageList),ListLast(ImageList))#"/>
<cfset FindImagePos = #ListFind(ImageList,ListRandImage)#>
<cfset NewImageList = #ListDeleteAt(ImageList , ListRandImage)#>
<cfset ImageList = NewImageList>

I'm so close but I cant get the ListLen to get smaller.

Any help is much appreciated,

Phil

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.775 / Virus Database: 522 - Release Date: 10/8/2004
 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Purchase from House of Fusion, a Macromedia Authorized Affiliate and support the CF 
community.
http://www.houseoffusion.com/banners/view.cfm?bannerid=35

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:182125
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to