Hi Andrew,

>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? 
>  
>
You need to be using the list functions;  ListFind and ListFindNoCase.  
Both of these functions take 2 mandatory and one optional parameters.  
listfind(list,value[,delimiter])

Using your code snippet above this is how you should use it.

<cfset prohibited_words = "alpha,bravo,charlie,delta">
<cfif ListFindNoCase(prohibited_words,form.name) GT 0>
<!--- Made a match --->
<cfelse>
<!--- No match found --->
</cfif>

Notice that I took the spaces out of your list of prohibited words.  
This is because the space will be interpreted as being a part of each 
value, unless you specify "[space] ,"  as the list delimiter.

As an aside, CONTAINS and ListContains will look for a your search term 
anywhere in the variable or list.
Take :
thislist = "them,the,these";
Writeoutput(listcontains(thislist,"the"));

This will actually return position 1 as the first result, because "them" 
contains "the".  To find "the" specifically, you need to use the above 
listfind functions.  The same holds true for CONTAINS.

Hope that helps.

Regards

Stephen



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

Message: http://www.houseoffusion.com/lists.cfm/link=i:15:582
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