• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Need help with auto suggest - Return multiple fields

Explorer ,
Apr 08, 2014 Apr 08, 2014

Copy link to clipboard

Copied

I am having a hard time getting my autosuggest to work. I have a cfinput where a person can type in a last name. I then want to return the full name and employee ID of the person and bind them to two different cfinputs. Here is my cfc:

<cfcomponent output="false">

 

          <cffunction name="getPerson" access="remote" returntype="array">

                    <cfargument name="search" type="any" required="false" default="">

 

 

                    <!--- Define variables --->

 

                     <cfset var data = "">

  <cfset var result = ArrayNew(2)>

  <cfset var i=0>

 

 

                    <!--- Query Location Table --->

                    <cfquery name="data" datasource="ds" cachedwithin="#CreateTimeSpan(0,14,0,0)#">

                              SELECT PERSONNEL.NAME_LAST_FIRST_MID, PERSONNEL.EMPLID, MST_LD.EMPLID

FROM MST_LD LEFT JOIN PERSONNEL ON MST_LD.SYREDU_SUID = PERSONNEL.EMPLID

WHERE ((MST_LD.PRIMARY_AFFIL_STATUS)= 'Active') AND ((MST_LD.EMPLID) Is Not Null)) AND PERSONNEL.NAME_LAST like <cfqueryparam cfsqltype="cf_sql_varchar" value="#ucase(arguments.search)#%" />

                              order by          name_last, name_first , EMPLID ASC

                    </cfquery>

 

              <cfloop index="i" from="1" to="#data.RecordCount#">

              <cftry>

         <cfset result[1]=data.NAME_LAST_FIRST_MID>

         <cfset result[2]=data.EMPLID>

         <cfcatch></cfcatch>

         </cftry>

        

      </cfloop>

       

                    <!--- And return it as a List --->

                    <cfreturn result>

          </cffunction>

</cfcomponent>

TOPICS
Advanced techniques

Views

328

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 08, 2014 Apr 08, 2014

Copy link to clipboard

Copied

LATEST

So what isn't working, specifically?  What are you getting back at the client end?  Also, you might want to post the <cfform> code block so we can see if anything is wrong with the bind(s). 

Lastly, you should consider not using <cfform> and <cfinput>, for a number of practical reasons.  Here are some ideas for suitable alternatives: https://github.com/cfjedimaster/ColdFusion-UI-the-Right-Way.

-Carl V.

Message was edited by: Carl Von Stetten

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation