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

Autosuggest with more data

Explorer ,
Jan 11, 2010 Jan 11, 2010

I have the autosuggest working with an <cfinput input field which calls a CFC function and returns the last name from a database.  While this is great, it would be nice to return more information than just the last name.  Is it possible to return "Last Name, First Name and Address Information" in the Autosuggest?  I want my user to see that Smith[1] is different than Smith[2] and so on.

Is this possible?

576
Translate
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
Advocate ,
Jan 11, 2010 Jan 11, 2010

NettlesD,

That is something which you need acheive in your query statement, In other words modify your current query to display the names the way you want.

ColdFusion's autosuggest will just display suggestions that are being returned from the query and has nothing to do with this requirement.

HTH

Translate
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
Valorous Hero ,
Jan 11, 2010 Jan 11, 2010

As Dave replied.  One set of strings is no different then another set of strings.

Modify your CFC to return the data the way you want it.

Translate
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
Explorer ,
Jan 11, 2010 Jan 11, 2010

Ah, so you just add that extra information you want.  This is what you are talking about?

What I currently have:

<cffunction name="Lookup" access="remote" returntype="array" output="no">
    <cfargument name="suggestvalue" required="true">
   
    <cfset var Results = ArrayNew(1)>
   
    <cfquery name="getDBNames" datasource="#application.DataSourceMDC#">
    select IFirstName,
           LastName
      from Registrant
       where lower(lastname) like <cfqueryparam value="#LCase(suggestvalue)#%" cfsqltype="cf_sql_varchar">
    </cfquery>
   
    <!--- Convert the query to an array. --->
    <cfloop query="getDBNames">
      <cfset arrayAppend(Results, LastName)>
    </cfloop>
  
    <cfreturn Results>
  </cffunction>

What I need to do:

<cffunction name="Lookup" access="remote" returntype="array" output="no">
    <cfargument name="suggestvalue" required="true">
   
    <cfset var Results = ArrayNew(1)>
   
    <cfquery name="getDBNames" datasource="#application.DataSourceMDC#">
    select LastName||', '||FirstName as Name
      from Registrant
       where lower(lastname) like <cfqueryparam value="#LCase(suggestvalue)#%" cfsqltype="cf_sql_varchar">
    </cfquery>
   
    <!--- Convert the query to an array. --->
    <cfloop query="getDBNames">
      <cfset arrayAppend(Results, Name)>
    </cfloop>
  
    <cfreturn Results>
  </cffunction>

Translate
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
Advocate ,
Jan 11, 2010 Jan 11, 2010

Yeah.. You are spot on!..


Translate
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
Explorer ,
Jan 11, 2010 Jan 11, 2010
LATEST

Is there an easy way to just grab the LastName and place that in the field versus all the extra information?  Meaning, the Autosuggest is a LastName input field but I needed "first name, address....so on" to better identify the person but I ONLY want LastName as the text in that field.  Is there a way to do that?

Oh, I take it you can't create a structure within an array and return that?

Translate
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