The function (ListContains) is doing exactly what it's suppose to and I can see why it's returning 4.
ListContains: Returns the index of the first item that contains a specified substring. The search is case-sensitive. If the substring is not found in the list items, it returns zero (0). Hence, when it comes across the word (site) in the codes list it does find the (case-sensitive) word of (site) within your vehicles list. You may want to use listFind() instead. -----Original Message----- From: Mark M. Kecko [mailto:[EMAIL PROTECTED]] Sent: Tuesday, March 05, 2002 1:59 PM To: CF-Talk Subject: Sorry to flood the List BUT.... ListContains NOT functioning properly! Sorry, but... Why does the below code check 4 boxes when there's only 3 items in the List??? Please help!!! This is costing my company a good deal of cash! - Just copy and paste the code into a test page and run it, you'll see, I hope. <cfset codes="siteMinute,siteNews,site,siteSpin,mi,os,ol,mn,siteHome"> <cfset Vehicles="siteMinute,siteNews,siteSpin"> <cfloop list="#codes#" index="i"> <cfoutput><input class=text type="checkbox" name="#i#" <cfif ListContains("#Vehicles#", "#i#")>checked</cfif>> #i#<br></cfoutput> </cfloop> Mark Kecko The Computer Guy MediaPost Communications [EMAIL PROTECTED] http://www.mediapost.com (203)222-0330 ext309 "Imagination is the one weapon in the war against reality." Jules de Gaultier -----Original Message----- From: Mark M. Kecko [mailto:[EMAIL PROTECTED]] Sent: Tuesday, March 05, 2002 12:32 PM To: CF-Talk Subject: ListContains NOT functioning properly - Help! Help! When I'm looping over a list Campaign.Vehicles that's coming from a SQL table varchar field I'm getting strange results from ListContains. Looping over Vehicles.cod= "siteMinute,siteNews,site,siteSpin,mi,os,ol,mn,siteHome" - several rows from a database call. Campaign.Vehicles="siteMinute,siteNews,site,siteSpin" - a 'static' database record. When Vehicles.code = "SiteSpin" the below "ListContains("#Campaign.Vehicles#", "#Vehicles.Code#")" returns 4. <cfloop query="Vehicles"> <input class=text type="checkbox" name="#Vehicles.Code#" <cfif ListContains("#Campaign.Vehicles#", "#Vehicles.Code#")>checked</cfif>> #Vehicles.Name#<br><br> </cfloop> Actual output to screen from testing: Campaign.Vehicles: siteMinute,siteNews,site,siteSpin Vehicles.Code: siteSpin ListContains - 4 As far as I can see from the output above siteSpin is only in the list Campaign.Vehicles once. Can anybody see something I can't. I've tried specifying the delimiter as a comma, changing the delimiter to a ~, setting the database field to a variable, changing the delimiters of that variable and I've tried all of those things with ListContainsNoCase as well. I've even tried changing the datatype of my SQL database field to nvarchar, ntext etc! Please help, this is holding up a very profitable ad campaign from being served on my site! Mark Kecko The Computer Guy MediaPost Communications [EMAIL PROTECTED] http://www.mediapost.com (203)222-0330 ext309 "Imagination is the one weapon in the war against reality." Jules de Gaultier ______________________________________________________________________ Dedicated Windows 2000 Server PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists