Solved

Can coldfusion autosuggest work on a substring within a string

Posted on 2009-07-16
4
370 Views
Last Modified: 2013-12-24
I have a coldfusion autosuggest set up in my form on an artist name which works ok. Currently it lists all names that start with the first letters a user has typed in i.e. Typing in "Geo" lists George Catlin. What I'd like to have happen is search on either last name, first name or perhaps if the string is contained in what the user has typed in so if a user types in Catlin it will list George Catlin.



My code is below:
 
<cfinput type="text" name="ObjectNumber" autosuggest="cfc:collections.ObjectNumberLookup({cfautosuggestvalue})" size="20" maxlength="20" typeahead="yes"></p>
 
 
<cfargument name="Search" type="any" required="no" default="">
    	<!--- Define Variable --->
        <cfset var data = "">
        <cfquery NAME="data" datasource="education">
            SELECT artist_name FROM studentPodcasts WHERE (artist_name LIKE '#Arguments.Search#%')
        </cfquery>
 
		<cfreturn ValueList(data.artist_name)>
 
</cffunction>

Open in new window

0
Comment
Question by:cbeverly
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 19

Expert Comment

by:Jones911
ID: 24869767
Swap your query to this:

<cfquery NAME="data" datasource="education">
            SELECT   artist_name
            FROM      studentPodcasts
            WHERE   ( artist_name LIKE '%#Arguments.Search#%' )
</cfquery>
0
 

Author Comment

by:cbeverly
ID: 24869789
I tried that but unfortunately it didn't work.
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 24869828
well try this
(artist_name LIKE '#Arguments.Search#%' or artist_lastname LIKE '#Arguments.Search#%')
0
 
LVL 19

Accepted Solution

by:
Jones911 earned 500 total points
ID: 24869841
That will work I can't see how I wont.
0

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question