Get ID element from CFC

View: New views
1 Messages — Rating Filter:   Alert me  

Get ID element from CFC

by Adam Parker-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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,
Adam


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4828
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.15