Link to home
Start Free TrialLog in
Avatar of J-Vo
J-Vo

asked on

Bind failed for autosuggest artname, bind value is not a 1D array of strings

I  am learning CF8 and I am trying to work with the Ajax stuff and when I try to dynamically assign the autosuggest to an input, I get the error: Bind failed for autosuggest artname, bind value is not a 1D array of strings.  I am at wits end.  I even made sure of the mappings of the CFIDE mappings with no luck.

I have included my cfinput tag and city.cfc code.  The cfinput is in a cfform tag.

I appreciate the help!
<cfinput type="text" name="City44" autosuggest="cfc:City.Cities({cfautosuggestvalue})" style="Width=250px;">
 
city.cfc:
<cfcomponent displayname="Cities">
	<cffunction access="remote" name="Cities" returntype="String">
		<cfargument name="Cty" type="string" required="No" default="">
 
		<cfset var zc = "">
 
		<cfquery datasource="ZipCodes" name="zc">
		Select Distinct City as citi
		From Zips
		Where City like <cfqueryparam value="#arguments.Cty#%" cfsqltype="CF_SQL_VARCHAR">
		Order by City
		</cfquery>
 
		<cfreturn ValueList(zc.Citi)>
	</cffunction>
</cfcomponent>

Open in new window

Avatar of SidFishes
SidFishes
Flag of Canada image

are you using onRequest ??

https://www.experts-exchange.com/questions/23110644/CF8-Bind-failed-for-autosuggest-s.html

I expect cf may be returning something other than a string (ie: some html as well perhaps)

I'd suggest picking up Firebug for Firefox. It's a free addon which will allow you to view post and response for ajax calls. If you are going to do any ajax, it's almost essential.

Avatar of J-Vo
J-Vo

ASKER

Thank you for your response!

First off, I put in a blank application.cfc so I should not be using the onRequest function.

I added the following line of code to invoke the cfc using the letter "O" to pull a list of cities from the cities.cfc.  This should be the exact same list returned to the autosuggest using the same CFC if you type in the letter "O".
<cfinvoke component="City" method="Cities" cty="o" returnvariable="Citis">
 
<cfoutput>#Citis#</cfoutput>

Open in new window

Avatar of J-Vo

ASKER

I added firebug to FireFox and here is what is returned for the letter "O":

O Brien,O Fallon,O Kean,O Neals,Oacoma,Oak,Oak Bluffs,Oak Brook,Oak City,Oak Creek,Oak Forest,Oak Grove,Oak Hall,Oak Harbor,Oak Hill,Oak Island,Oak Lawn,Oak Park,Oak Ridge,Oak Run,Oak Vale,Oak View,Oakboro,Oakdale,Oakes,Oakesdale,Oakfield,Oakford,Oakham,Oakhurst,Oakland,Oakland City,Oakland Gardens,Oakland Mills,Oakley,Oaklyn,Oakman,Oakmont,Oakpark,Oakridge,Oaks,Oaks Corners,Oakton,Oaktown,Oakvale,Oakville,Oakwood,Oark,Oasis,Oatman,Oberlin,Obernburg,Oberon,Obion,Oblong,Obrien,Ocala,Ocate,Occidental,Occoquan,Ocean Beach,Ocean Bluff,Ocean City,Ocean Gate,Ocean Grove,Ocean Isle Beach,Ocean Park,Ocean Shores,Ocean Springs,Ocean View,Oceana,Oceano,Oceanport,Oceanside,Oceanville,Oceola,Ochelata,Ocheyedan,Ochlocknee,Ochopee,Ocilla,Ocklawaha,Ocoee,Oconee,Oconomowoc,Oconto,Oconto Falls,Ocotillo,Ocracoke,Odanah,Odd,Odebolt,Odell,Odem,Oden,Odenton,Odenville,Odessa,Odin,Odon,Odonnell,Odum,Oelrichs,Oelwein,Offerle,Offerman,Offutt AFB,Ogallah,Ogallala,Ogden,Ogdensburg,Ogema,Ogilvie,Oglala,Oglesby,Oglethorpe,Ogunquit,Ohatchee,Ohio,Ohio City,Ohiopyle,Ohiowa,Ohley,Ohlman,Oil City,Oil Springs,Oil Trough,Oilmont,Oilton,Oilville,Ojai,Ojibwa,Ojo Caliente,Ojo Feliz,Okabena,Okahumpka,Okanogan,Okarche,Okatie,Okaton,Okauchee,Okawville,Okay,Okeana,Okeechobee,Okeene,Okemah,Okemos,Oketo,Oklahoma City,Oklaunion,Oklee,Okmulgee,Okoboji,Okolona,Okreek,Oktaha,Ola,Olalla,Olamon,Olancha,Olanta,Olar,Olathe,Olaton,Olcott,Old Appleton,Old Bethpage,Old Bridge,Old Chatham,Old Fields,Old Forge,Old Fort,Old Glory,Old Greenwich,Old Harbor,Old Hickory,Old Lyme,Old Mission,Old Monroe,Old Mystic,Old Ocean,Old Orchard Beach,Old Saybrook,Old Station,Old Town,Old Washington,Old Westbury,Old Zionsville,Olden,Oldenburg,Oldfield,Oldfort,Oldham,Oldhams,Olds,Oldsmar,Oldtown,Oldwick,Olean,Olema,Oley,Olga,Olin,Olive,Olive Branch,Olive Hill,Olivebridge,Oliveburg,Olivehill,Olivehurst,Oliver,Oliver Springs,Olivet,Olivia,Olla,Ollie,Olmito,Olmitz,Olmstead,Olmsted,Olmsted Falls,Olmstedville,Olney,Olney Springs,Olpe,Olsburg,Olton,Olustee,Olympia,Olympia Fields,Olympic Valley,Olyphant,Omaha,Omak,Omar,Omega,Omena,Omer,Omro,Ona,Onaga,Onaka,Onalaska,Onamia,Onancock,Onarga,Onawa,Onaway,Oneco,Onego,Oneida,Oneill,Onekama,Onemo,Oneonta,Ong,Onia,Onida,Onley,Only,Ono,Onondaga,Onset,Onslow,Onsted,Ontario,Ontario Center,Ontonagon,Onward,Onyx,Ookala,Oolitic,Oologah,Ooltewah,Oostburg,Opa Locka,Opal,Opdyke,Opelika,Opelousas,Opheim,Ophelia,Ophiem,Ophir,Opolis,Opp,Oquawka,Oquossoc,Ora,Oracle,Oradell,Oral,Oran,Orange,Orange Beach,Orange City,Orange Cove,Orange Grove,Orange Lake,Orange Park,Orange Springs,Orangeburg,Orangefield,Orangevale,Orangeville,Oraville,Orbisonia,Orcas,Orchard,Orchard Hill,Orchard Park,Ord,Orderville,Ordinary,Ordway,Ore City,Oreana,Orefield,Oregon,Oregon City,Oregon House,Oregonia,Oreland,Orem,Orestes,Orford,Orfordville,Organ,Orgas,Orick,Orient,Oriental,Orinda,Orion,Oriska,Oriskany,Oriskany Falls,Orkney Springs,Orla,Orland,Orland Park,Orlando,Orlean,Orleans,Orlinda,Orma,Ormond Beach,Ormsby,Oro Grande,Orocovis,Orofino,Orogrande,Orondo,Orono,Oronoco,Oronogo,Orosi,Orovada,Oroville,Orr,Orrick,Orrin,Orrington,Orrs Island,Orrstown,Orrtanna,Orrum,Orrville,Orson,Orting,Ortley,Ortonville,Orviston,Orwell,Orwigsburg,Osage,Osage Beach,Osage City,Osakis,Osawatomie,Osborn,Osborne,Osburn,Oscar,Osceola,Osceola Mills,Osco,Oscoda,Osgood,Oshkosh,Oshtemo,Oskaloosa,Oslo,Osmond,Osnabrock,Osprey,Osseo,Ossian,Ossineke,Ossining,Ossipee,Osteen,Osterburg,Osterville,Ostrander,Oswegatchie,Oswego,Osyka,Otego,Othello,Otho,Otis,Otis Orchards,Otisco,Otisville,Otley,Oto,Otoe,Otsego,Ottawa,Ottawa Lake,Otter,Otter Creek,Otter Lake,Otter Rock,Otterbein,Ottertail,Otterville,Ottine,Otto,Ottosen,Ottoville,Ottsville,Ottumwa,Otway,Otwell,Ouaquaga,Ouray,Outing,Outlook,Ouzinkie,Ovalo,Ovando,Ovapa,Overbrook,Overgaard,Overland Park,Overpeck,Overton,Ovett,Ovid,Oviedo,Owaneco,Owanka,Owasso,Owatonna,Owego,Owen,Owendale,Owens Cross Roads,Owensboro,Owensburg,Owensville,Owenton,Owings,Owings Mills,Owingsville,Owls Head,Owosso,Owyhee,Oxbow,Oxford,Oxford Junction,Oxly,Oxnard,Oxon Hill,Oyens,Oyster,Oyster Bay,Oysterville,Ozan,Ozark,Ozawkie,Ozona,Ozone,Ozone Park
do these entries

 O Brien,O Fallon,O Kean,O Neals,

have '
ie: O'Brien

if so, it's possible that cf is seeing the quotes as a part of the array structure

what happens when you change the cfc to

        <cffunction access="remote" name="Cities" returntype="String">
                <cfargument name="Cty" type="string" required="No" default="">
 
                <cfset zc = "Onset,Onslow,Onsted">
 
                <cfreturn zc>
        </cffunction>

Open in new window

Avatar of J-Vo

ASKER

I put i your code and it returns just the three cities, but I still get the same error.

I'm not sure if its seeing the qotes or not, but it doesn't appear to be displaying them when the page loads and I invoke the cfc.
<cfcomponent displayname="Cities">
 
        <cffunction access="remote" name="Cities" returntype="String">
                <cfargument name="Cty" type="string" required="No" default="">
 
                <cfset zc = "Onset,Onslow,Onsted">
 
                <cfreturn zc>
        </cffunction>
	
</cfcomponent>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of SidFishes
SidFishes
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of J-Vo

ASKER

You totally rock!  I got it to work!

I changed the return type in the cffunction to "Array" and then added the ListToArray in my return and it's working perfectly!!!

I REALLY appreciate the help!

I'll post my code below to help others who might run into the same problems.
<cfinput type="text" name="City44" autosuggest="cfc:City.Cities({cfautosuggestvalue})" style="Width=250px;">
 
 
<cfcomponent displayname="Cities">
 
<cffunction access="remote" name="Cities" returntype="array">
	
		<cfargument name="Cty" type="string" required="No" default="">
		
		<cfset var zc = "">
		<cfset var lst = "">
 
		<cfquery datasource="ZipCodes" name="zc">
		Select Distinct City as citi
		From Zips
		Where City like <cfqueryparam value="#arguments.Cty#%" cfsqltype="CF_SQL_VARCHAR">
		Order by City
		</cfquery>
 
		<cfset lst = ValueList(zc.Citi)>
		
		<cfreturn listToArray(lst)>
		
	</cffunction>	
 
</cfcomponent>

Open in new window

ok,,, i think the problem is with your sql...you don't need the like clause

try this

<cffunction access="remote" name="Cities" returntype="string">
            <cfargument name="Cty" type="string" required="No" default="">
 
            <cfset TempQry= querynew("")>
            <cfset queryaddcolumn  (TempQry, "Col2", "cf_sql_varchar", ListToArray("o'here, there, everywhere, home, nowhere, anywhere, somewhere"))>
            
            <cfquery dbtype="query" name="Test">
            select col2 from tempqry
            </cfquery>            

                 <cfreturn valuelist(test.col2)>
        </cffunction>


it works for me  


if it works for you try this


   <cffunction access="remote" name="Cities" returntype="String">
                <cfargument name="Cty" type="string" required="No" default="">
 
               
                <cfquery datasource="ZipCodes" name="zc">
                Select City as citi
                From Zips
                Order by City
                </cfquery>
 
                <cfreturn ValueList(zc.Citi)>
        </cffunction>

glad you got it working...

so it seems it wasn't the like clause but it looks like it is not necessary as the autosuggest magic behind the scenes does that...
"Bind failed for autosuggest, bind value is not a 1D array of strings"

I figured out this problem even further:

I found this worked for autosuggest fields (using a sting instead of array) plus add a ",none" to the end of the ValueList result:

<cffunction access="remote" name="ProductIDs" returntype="String">
<cfargument name="pIDValue" type="string" required="No" default="">
<cfquery datasource="myDatasource" name="myQuery">
Select pID as ProductID
From products
</cfquery>
<cfreturn ValueList(myQuery.ProductID) & ",none">

***",none" could be any other string not associated to the search like 'n/a' I suppose.***

</cffunction>

I believe the issue is with the JSON file included in CF8.

I found that when you enter a number in rapidly you would still get the "bind" error so I solved the problem doing this. It tricks the "invocation". It seems the invocation response will return a value like 10020.0 when you enter a value of 10020 quickly?