Solved

Can coldfusion autosuggest work on a substring within a string

Posted on 2009-07-16
4
361 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
  • 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now