<cfset input = 100 />
<cfset last = listFirst(numbers) />
<cfloop list="#numbers#" index="num">
<cfif num GT input>
<cfbreak />
</cfif>
<cfset last = num />
</cfloop>
#last#
I didn't test that code, but it should work, subject to correcting any
fat fingering on my part.
cheers,
barneyb
On 10/2/07, Andy Matthews <[EMAIL PROTECTED]> wrote:
> Say that I have a list of allowed nmbers:
> 32,48,64,72,144,160,200,288,320,400,512,576,640,720,800
>
> If I give the user the option of selecting a number, and it happens to not be
> in this list, how might I go about automagically selecting the next lowest
> number? One exception being if the user selects a number lower than 32, in
> which case the code should return 32.
>
> Examples:
> User selects 100, the code would return 72.
> User selects 480, the code would return 400.
> User selects 25, the code would return 32.
>
> Currently the numbers are stored in a simple list, but I have control over
> that list and they can be in whatever format makes the most sense. One caveat
> is that they need to stay in code (so no database interaction).
>
--
Barney Boisvert
[EMAIL PROTECTED]
http://www.barneyb.com/
Got Gmail? I have 100 invites.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Download the latest ColdFusion 8 utilities including Report Builder,
plug-ins for Eclipse and Dreamweaver updates.
http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290036
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4