Get ID element from CFC
Hello -
I'm attempting to use my first CFC in conjunction with cfinput and autosuggest. As is currently, everything works as far as the autosuggestion goes. My simple form is this:
<cfform action="#cgi.SCRIPT_NAME#">
Client: <cfinput type="text"
name="client"
autosuggest="cfc:client.lookupClient({cfautosuggestvalue})" size="90">
<br />
<input type="submit" value="Save">
</cfform>
My CFC is:
<cfcomponent output="false">
<cfset THIS.dsn="myDSN">
<!--- Lookup used for auto suggest --->
<cffunction name="lookupClient" access="remote" returntype="array">
<cfargument name="search" type="any" required="false" default="">
<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(1)>
<!--- Do search --->
<cfquery datasource="#THIS.dsn#" name="data">
SELECT clientID,firstName,lastName,email,organization FROM client
WHERE UCase(lastname) LIKE Ucase('#ARGUMENTS.search#%')
ORDER by lastname, firstname
</cfquery>
<!--- Build result array --->
<cfloop query="data">
<cfset name = '#lastname#, #firstname# (#email# - #organization#), #clientID#'>
<cfset ArrayAppend(result, #name#)>
</cfloop>
<!--- And return it --->
<cfreturn result>
</cffunction>
</cfcomponent>
The data returns to the textbox formatted how I want it to be; however, when the form submits, I only want the ID to post to the record. How may I obtain the ID from the CFC to use it in a hidden field of the form so the associated ID of the client posts to the database record?
Thank you
