954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

problem in autocomplete in jsp translated from coldfusion version

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>
tapuwa2002
Newbie Poster
22 posts since Dec 2008
Reputation Points: 10
Solved Threads: 1
 


Can't help you with jquery. But why not just use CF's built in autosuggest? Are you running CF8 or higher? http://tutorial7.learncf.com/

arrgh
Posting Whiz
381 posts since Dec 2008
Reputation Points: 32
Solved Threads: 47
 

I will try your link thanks :)

tapuwa2002
Newbie Poster
22 posts since Dec 2008
Reputation Points: 10
Solved Threads: 1
 

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:
    <cfinput type="text" name="parkname" size="50" autosuggest="cfc:autosuggest.findPark({cfautosuggestvalue})" autosuggestminlength="1" maxresultsdisplayed="10" />
</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.

tapuwa2002
Newbie Poster
22 posts since Dec 2008
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You