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
Solved

Can coldfusion autosuggest work on a substring within a string

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

839 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