Downloaded autocomplete plugin. its not bring out results am using an access db. When I type in text it does the search but with no proposed results display in the drop down.
Is there something missing?

<cfsetting enablecfoutputonly="true">
<cfparam name="q" default="" />
<cfquery name="qryGetCountry" datasource="dbtest">
SELECT DISTINCT Cities.RegionCity
FROM Cities
WHERE Cities.RegionCity LIKE <cfqueryparam value="#URL.q#*"/>
</cfquery>
<cfoutput query="qryGetCountry">
#qryGetCountry.countryName##chr(10)#
</cfoutput>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
	<title>Auto Complete - jQuery</title>
	<script type="text/javascript" src="scripts/jquery-1.2.6.min.js"></script>
	<script type="text/javascript" src="scripts/jquery.autocomplete.js"></script>
	<link type="text/css" href="styles/autocomplete.css" rel="stylesheet" media="screen" />

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

			$("#city").autocompleteArray(
				["Bath","Birmingham","Bradford","Brighton and Hove","Bristol",
				"Cambridge","Canterbury","Carlisle","Chester","Chichester",
				"Coventry","Derby","Durham","Ely","Exeter","Gloucester","Hereford",
				"Kingston upon Hull","Lancaster","Leeds","Leicester","Lichfield",
				"Lincoln","Liverpool","London","Manchester","Newcastle-upon-Tyne",
				"Norwich","Nottingham","Oxford","Peterborough","Plymouth","Portsmouth",
				"Preston","Ripon","Salford","Salisbury","Sheffield","Southampton",
				"St Albans","Stoke-on-Trent","Sunderland","Truro","Wakefield","Wells",
				"Westminster","Winchester","Wolverhampton","Worcester","York"],
				{
					minChars:1,
					delay:10,
					autoFill:true,
					matchSubset:1,
					matchContains:1,
					selectOnly:1
				}
			);
		});
	</script>
</head>
<body>

<h1>Auto Complete</h1>
<h2>jQuery</h2>
<h3>Example 1.: Country Lookup</h3>
<p>Using <abbr title="Asynchronous JavaScript and XML">AJAX</abbr> to interrogate the database.</p>
<p>Example data: Australia, Bulgaria, United Kingdom</p>
<form name="frmAutoCompleteCountry" id="frmAutoCompleteCountry" action="#" method="post">
<p>
<label for="country">Country</label>
<input type="text" name="country" id="country" />
</p>
</form>
<p>NB. If you have <a href="http://getfirebug.com/" title="Get Firebug">Firebug</a> installed you will be able to view the <abbr title="Asynchronous JavaScript and XML">AJAX</abbr> call.</p>
<h3>Example 2.: City Lookup</h3>
<p>Using a local array to populate data.</p>
<p>Example data: Bradford, Leeds, Salisbury, York</p>
<form name="frmAutoCompleteCity" id="frmAutoCompleteCity" action="#" method="post">
<p>
<label for="city">City</label>
<input type="text" name="city" id="city" />
</p>
</form>
</body>
</html>

Recommended Answers

All 3 Replies

I will try your link thanks :)

I have uploaded the demo but its not functioning, I have an access database with a list of countries. I want it to autocomplete the countries based on the demo I have left the javascript id for the form elements as is. My demo code is as following:

<!--- A simple form for auto suggest --->
<cfform action="autosuggest.cfm" method="post">
	Park Name:<br />
    <cfinput type="text" name="parkname" size="50" autosuggest="cfc:autosuggest.findPark({cfautosuggestvalue})" autosuggestminlength="1" maxresultsdisplayed="10" /><br /><br />
</cfform>

The function as mentioned in the tutorial

<cfcomponent output="false">

	<!--- Lookup used for auto suggest --->
	<cffunction name="findPark" access="remote" returntype="string">
		<cfargument name="search" type="any" required="false" default="">
		
		<!--- Define variables --->
		<cfset var local = {} />
		
		<!--- Query Location Table --->
		<cfquery name="local.query" datasource="dbtest" >
			select		Country
			from		Cities
			where		Country like <cfqueryparam cfsqltype="cf_sql_varchar" value="#ucase(arguments.search)#%" />
			order by	Country
		</cfquery>

		<!--- And return it as a List --->
		<cfreturn valueList(local.query.Country)>
	</cffunction>

</cfcomponent>

In for instance you change the statement and it should work. Please help :) is there anything I left out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.