Hi Andrew, you can leave out the loop and use ListFind()/ListFindNoCase() to
compare the list elements to your form field.

<cfset prohibited_words = "alpha,bravo,charlie,delta">

<cfif ListFindNoCase(prohibited_words, FORM.name, ",")>
        <!--- Dodgy word found --->
<cfelse>
        <!--- All clear --->
</cfif>

Also, your list elements have spaces before them, it may help with
readability but when comparing them it'll fail due to the extra space.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 02 February 2005 04:42
To: CF-Newbie
Subject: Comparing List Values


Hi to all,

I'm relatively new to CF and am trying to compare the value of a form field
(form.name) with a values of a list to see if the name entered in the form
field matches a name in the list. I am using a CFSET variable to store the
list values.

I am able to cycle throught the list using a for loop (cfloop) and am able
to output the list results using cfoutput, however this is not what I want
at the moment. Heres a rough example of the code (minus the for loop):

<cfset prohibited_words = "alpha, bravo, charlie, delta">

<cfif (form.name) contains prohibited_words>

The above snippet will only ever compare the first word of the list with the
value stored in form.name. I am looking for a way to cycle through the
complete list and compare the list values with the form value at the same
time.

Can anyone help?

cheers

Andrew H
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.8.2 - Release Date: 28/01/2005


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

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

Reply via email to