INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

autosuggest (cfc and jquery) help

autosuggest (cfc and jquery) help

(OP)
Hi All,

I have couple of question and need some help on my task. Im stucked and need to see my error. Please help.
Basically, I just need to an autosuggest on my input text.

(form.cfm)

CODE -->

<html>
<head>
	 <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/redmond/jquery-ui.css">

	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
	<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>

<title>Untitled Document</title>

<script>
	$(function() {
				$("#company").autocomplete({
					//source: "states.cfm",
					source: "cfc/S_Company.cfc",
					minLength: 1,
					select: function(event, ui) {
						//$('#id').val(ui.item.id);
						//$('#abbrev').val(ui.item.abbrev);
					}
				});
			});
</script>
</head>
<cfsilent>
	<cfinvoke component="cfc.S_Company" method="autosuggest">
		<cfinvokeargument name="searchPhrase" value="#url.searchPhrase#">
	</cfinvoke>
</cfsilent>	
<body>


	
<!--- 	<cfinvoke component="_cfc/autocomplete"  method="BrandAffiliations"returnvariable="BrandAffiliations"/> --->


<form action="index.cfm"  method="post">


<p class="ui-widget"><label for="company">Company Name : </label>
    <input type="text" id="company"  name="company" /> 
</p>

<p><input type="submit" name="submit" value="Submit" /></p>

</form>


</body>
</html> 


Here's my component file : (S_Company.cfc) in a directory "cfc"

CODE -->

<cfcomponent>
	<cffunction name="autosuggest" access="remote">
	
		
		<cfargument name="searchPhrase" type="any" />
		
		<cfset returnArray = arrayNew(1) />
		<cfset var id = 'id' />
		<cfset var d_company_name = 'd_company_name' />
		
		<cfquery name="qryCompany" dataSource="db_source">
			Select * 
			FROM table_company
			WHERE d_company_name like <cfqueryparam value="%#Arguments.searchPhrase#%" cfsqltype="cf_sql_varchar">
		</cfquery>		
		
	<cfloop query="qryCompany">
		<cfset compStruct = StructNew() />
		<cfset compStruct["id"] = id />
		<cfset compStruct["d_company_name"] = d_company_name />
		 
		<cfset ArrayAppend(returnArray,compStruct) />
	</cfloop>
	
		<cfoutput>
		#serializeJSON(returnArray)#
		</cfoutput>				

		

	</cffunction>
</cfcomponent> 

My table is table_company
Columns: id, d_company_name, abbrev


Cannot make it work.Problem might be in jquery or in my CFC. Please help.

Thank you very much.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close