Coldfusion and jquery autocomplete (using remote data)

Hi All.

I'd like to use an auto complete on a name field in my form using JQUERY and COLDFUSION.

I'm working from the http://www.simonwhatley.co.uk/examples/autocomplete/jquery/ tutorial but I seem to be coming unstuck, hence posting on here.

My code is provided below, i believe where im getting it wrong is the suggestion.cfm page where I actually call the data.

Can anyone shed some light on this for me?

thanks
<script type="text/javascript">
		$(document).ready(function() {
			$("#inputtest").autocomplete(
				"../suggestions.cfm",
				{
					minChars:2,
					delay:100,
					autoFill:false,
					matchSubset:false,
					matchContains:1,
					cacheLength:10,
					selectOnly:1
				}
			);

			
		});


</script>




<input type="text" name="inputtest" id="inputtest" />




<!--- code below for suggestions.cfm --->


<cfsetting enablecfoutputonly="true">
<cfparam name="q" default="" />
<cfquery name="qry" datasource="afm_fire">
SELECT em_name 
FROM afm.em
WHERE em_name LIKE <cfqueryparam value="#URL.q#%" cfsqltype="cf_sql_varchar" />
</cfquery>
<cfoutput query="qryGetCountry">
#qry.em_name##chr(10)#
</cfoutput>

Open in new window

LVL 2
CurtinPropAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

azadisaryevCommented:
>> <cfquery name="qry"
>> <cfoutput query="qryGetCountry">

looks like you are outputting a wrong query?

Azadi
0
azadisaryevCommented:
you should also correct your <cfparam> tag:

<cfparam name="URL.q" default="">

Azadi
0
CurtinPropAuthor Commented:
My apologies, having made those changes I get an interesting result.

When a user starts to type into the input area, the autocomplete appears to work but it outputs an empty list of suggestions and when I select one of them it populates the input area with lines from the doctype and heading.

Im assuming its picking up lines of the source from suggestions.cfm??

I've attached an imagine showing the drop down, hopefully it makes sense.
auto-comp-screen1.jpg
0
azadisaryevCommented:
it looks like your Application.cfm/cfc is outputting those lines. they, obviously, break the data returned from your page...

you could probably do something like this in your Application.cfm to disable it for suggestions.cfm page:

<cfif getfilefrompath(cgi.script_name) neq 'suddestions.cfm>
<!--- output page headers here --->
</cfif>

Azadi
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.