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!
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>
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".
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>
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,Oa kham,Oakhu rst,Oaklan d,Oakland City,Oakland Gardens,Oakland Mills,Oakley,Oaklyn,Oakman ,Oakmont,O akpark,Oak ridge,Oaks ,Oaks Corners,Oakton,Oaktown,Oak vale,Oakvi lle,Oakwoo d,Oark,Oas is,Oatman, Oberlin,Ob ernburg,Ob eron,Obion ,Oblong,Ob rien,Ocala ,Ocate,Occ idental,Oc coquan,Oce an Beach,Ocean Bluff,Ocean City,Ocean Gate,Ocean Grove,Ocean Isle Beach,Ocean Park,Ocean Shores,Ocean Springs,Ocean View,Oceana,Oceano,Oceanpo rt,Oceansi de,Oceanvi lle,Oceola ,Ochelata, Ocheyedan, Ochlocknee ,Ochopee,O cilla,Ockl awaha,Ocoe e,Oconee,O conomowoc, Oconto,Oco nto Falls,Ocotillo,Ocracoke,Od anah,Odd,O debolt,Ode ll,Odem,Od en,Odenton ,Odenville ,Odessa,Od in,Odon,Od onnell,Odu m,Oelrichs ,Oelwein,O fferle,Off erman,Offu tt AFB,Ogallah,Ogallala,Ogden ,Ogdensbur g,Ogema,Og ilvie,Ogla la,Oglesby ,Oglethorp e,Ogunquit ,Ohatchee, Ohio,Ohio City,Ohiopyle,Ohiowa,Ohley ,Ohlman,Oi l City,Oil Springs,Oil Trough,Oilmont,Oilton,Oilv ille,Ojai, Ojibwa,Ojo Caliente,Ojo Feliz,Okabena,Okahumpka,Ok anogan,Oka rche,Okati e,Okaton,O kauchee,Ok awville,Ok ay,Okeana, Okeechobee ,Okeene,Ok emah,Okemo s,Oketo,Ok lahoma City,Oklaunion,Oklee,Okmul gee,Okoboj i,Okolona, Okreek,Okt aha,Ola,Ol alla,Olamo n,Olancha, Olanta,Ola r,Olathe,O laton,Olco tt,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,Ol dham,Oldha ms,Olds,Ol dsmar,Oldt own,Oldwic k,Olean,Ol ema,Oley,O lga,Olin,O live,Olive Branch,Olive Hill,Olivebridge,Oliveburg ,Olivehill ,Olivehurs t,Oliver,O liver Springs,Olivet,Olivia,Olla ,Ollie,Olm ito,Olmitz ,Olmstead, Olmsted,Ol msted Falls,Olmstedville,Olney,O lney Springs,Olpe,Olsburg,Olton ,Olustee,O lympia,Oly mpia Fields,Olympic Valley,Olyphant,Omaha,Omak ,Omar,Omeg a,Omena,Om er,Omro,On a,Onaga,On aka,Onalas ka,Onamia, Onancock,O narga,Onaw a,Onaway,O neco,Onego ,Oneida,On eill,Oneka ma,Onemo,O neonta,Ong ,Onia,Onid a,Onley,On ly,Ono,Ono ndaga,Onse t,Onslow,O nsted,Onta rio,Ontari o Center,Ontonagon,Onward,On yx,Ookala, Oolitic,Oo logah,Oolt ewah,Oostb urg,Opa Locka,Opal,Opdyke,Opelika, Opelousas, Opheim,Oph elia,Ophie m,Ophir,Op olis,Opp,O quawka,Oqu ossoc,Ora, Oracle,Ora dell,Oral, Oran,Orang e,Orange Beach,Orange City,Orange Cove,Orange Grove,Orange Lake,Orange Park,Orange Springs,Orangeburg,Orangef ield,Orang evale,Oran geville,Or aville,Orb isonia,Orc as,Orchard ,Orchard Hill,Orchard Park,Ord,Orderville,Ordina ry,Ordway, Ore City,Oreana,Orefield,Orego n,Oregon City,Oregon House,Oregonia,Oreland,Ore m,Orestes, Orford,Orf ordville,O rgan,Orgas ,Orick,Ori ent,Orient al,Orinda, Orion,Oris ka,Oriskan y,Oriskany Falls,Orkney Springs,Orla,Orland,Orland Park,Orlando,Orlean,Orlean s,Orlinda, Orma,Ormon d Beach,Ormsby,Oro Grande,Orocovis,Orofino,Or ogrande,Or ondo,Orono ,Oronoco,O ronogo,Oro si,Orovada ,Oroville, Orr,Orrick ,Orrin,Orr ington,Orr s Island,Orrstown,Orrtanna,O rrum,Orrvi lle,Orson, Orting,Ort ley,Ortonv ille,Orvis ton,Orwell ,Orwigsbur g,Osage,Os age Beach,Osage City,Osakis,Osawatomie,Osb orn,Osborn e,Osburn,O scar,Osceo la,Osceola Mills,Osco,Oscoda,Osgood,O shkosh,Osh temo,Oskal oosa,Oslo, Osmond,Osn abrock,Osp rey,Osseo, Ossian,Oss ineke,Ossi ning,Ossip ee,Osteen, Osterburg, Osterville ,Ostrander ,Oswegatch ie,Oswego, Osyka,Oteg o,Othello, Otho,Otis, Otis Orchards,Otisco,Otisville, Otley,Oto, Otoe,Otseg o,Ottawa,O ttawa Lake,Otter,Otter Creek,Otter Lake,Otter Rock,Otterbein,Ottertail,O tterville, Ottine,Ott o,Ottosen, Ottoville, Ottsville, Ottumwa,Ot way,Otwell ,Ouaquaga, Ouray,Outi ng,Outlook ,Ouzinkie, Ovalo,Ovan do,Ovapa,O verbrook,O vergaard,O verland Park,Overpeck,Overton,Ovet t,Ovid,Ovi edo,Owanec o,Owanka,O wasso,Owat onna,Owego ,Owen,Owen dale,Owens Cross Roads,Owensboro,Owensburg, Owensville ,Owenton,O wings,Owin gs Mills,Owingsville,Owls Head,Owosso,Owyhee,Oxbow,O xford,Oxfo rd Junction,Oxly,Oxnard,Oxon Hill,Oyens,Oyster,Oyster Bay,Oysterville,Ozan,Ozark ,Ozawkie,O zona,Ozone ,Ozone Park
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
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
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>
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.
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>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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>
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>
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...
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.ProductI D) & ",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?
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.ProductI
***",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?
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.