James,
Try this
<cfset list="23,24,27,30,543,675,980">
<!--- current_number would be dynamic, right now it's set to 543 --->
<cfset current_number=543>
<cfset position=ListFind(list,current_number)>
<cfloop list="#list#" index="count">
<cfset previous_number=ListGetAt(list,position-1)>
<cfset next_number=ListGetAt(list,position+1)>
</cfloop>
<cfoutput>
Previous Number: #previous_number#<br>
Current Number: #current_number#<br>
Next Number: #next_number#
</cfoutput>
You will run into problems with the first and last number in the list but
this should give you a start and i'm sure you'll be able to find a
workaround.
Dennis Baldwin
-----Original Message-----
From: James Maltby [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 23, 2001 9:28 AM
To: CF-Talk
Subject: Find position in a list
Hi
Let's imagine I've got a list of id numbers and a specific id number within
this list. How could I output the "next" id number in the list and the
"previous" id number in the list, depending on the id number I have?
e.g. List = 23,24,27,30,543,675,980 AND id=543 - I need to get either 30 or
675, then if I get 675 I need to get 543 or 980, etc. etc.
TIA
James
"The Force is strong in this one..."
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists