Copy link to clipboard
Copied
This seems a bit strange. As I enter text (even slowly) the autosuggest only seems to display after every 2nd character entered.
You can view the problem at http://karaoke.com.au in the search fields. It occurs in all 3 search entry fields (Disc, Title and Artist) In addition, as you remove characters, the autosuggset doesn't always update either?
Any autosuggestions anyone?
Copy link to clipboard
Copied
I don't see what you're seeing. It all seems fine to me (tested in IE8 and FF3). Did you fix it?
It always helps when you have a problem if you post some code which replicates the problem, so anyone trying to help can either eyeball it for obvious mistakes, or run it locally. Not necessarily your production code, but a simple test case that demonstrates the issue. This also help you track down what the problem might be.
--
Adam
Copy link to clipboard
Copied
Hey Adam,
Thanks for taking the time to take a look. I'm a bit surprised that you are getting the correct result there? I tested in IE8 and FF3 as well.
As you type in a title, say, "To all the girls I've loved before" as you type the "T" I'm expecting the autosuggest to start suggesting my top 20 of titles beginning with "T" but, what I see is the little ajax loading spinner and then nothing until after I type in the next 2 characters when all of a sudden, I get the autosuggest. Having got the autosuggest displayed once, when I start deleting characters, I tend to get the expected behaviour as I go back one character at a time. Please note that no matter how slow I go, I still get these symptoms???
Anyway here's my code for the form:
<div class="search_element">
<label for="disc">Disc</label><br />
<cfinput style="width:60px;height:16px;" name="disc" value="#request.search.songs.disc#" autosuggest="cfc:karaoke.com.auto_suggest.find_disc({cfautosuggestvalue})" autosuggestminlength="1" maxresultsdisplayed="20">
</div>
<div class="search_element">
<label for="disc">Title</label><br />
<cfinput style="width:130px;height:16px;" name="title" value="#request.search.songs.title#" autosuggest="cfc:karaoke.com.auto_suggest.find_title({cfautosuggestvalue})" autosuggestminlength="1" maxresultsdisplayed="20"></cfinput>
</div>
<div class="search_element">
<label for="disc">Artist</label><br />
<cfinput style="width:130px;height:16px;" name="artist" value="#request.search.songs.artist#" autosuggest="cfc:karaoke.com.auto_suggest.find_artist({cfautosuggestvalue})" autosuggestminlength="1" maxresultsdisplayed="20"></cfinput>
</div>
And here's the CFC:
<cfcomponent output="true">
<cffunction name="find_disc" access="remote" returntype="string">
<cfargument name="search" type="any" required="false" default="">
<!--- Query discs --->
<cfquery name="results" datasource="#dsn#" maxrows="20" >
select distinct discs.disc
from discs
where disc like '#arguments.search#%'
order by disc
</cfquery>
<!--- And return it as a List --->
<cfreturn valueList(results.disc) >
</cffunction>
<cffunction name="find_title" access="remote" returntype="string">
<cfargument name="search" type="any" required="false" default="">
<!--- Query discs --->
<cfquery name="results" datasource="#dsn#" maxrows="20" >
select distinct discs.title
from discs
where title like '#arguments.search#%'
order by title
</cfquery>
<!--- And return it as a List --->
<cfreturn valueList(results.title) >
</cffunction>
<!--- Lookup used for auto suggest --->
<cffunction name="find_artist" access="remote" returntype="string">
<cfargument name="search" type="any" required="false" default="">
<!--- Query discs --->
<cfquery name="results" datasource="#dsn#" maxrows="20" >
select distinct discs.artist
from discs
where artist like '#arguments.search#%'
order by artist
</cfquery>
<!--- And return it as a List --->
<cfreturn valueList(results.artist) >
</cffunction>
</cfcomponent>
Copy link to clipboard
Copied
I tried it last night with FF3 and did not see that behavior either.
Copy link to clipboard
Copied
Thanks to both of you for your assistance. I'm still seeing the prob both locally and remotely. I cant see that a browser setting could influence it, so other than that I'm a bit lost.so unless someone else raises it with me, I'll probably just leave as is. Thanks again for your time.
Copy link to clipboard
Copied
Hold the bus, an (off forum) friend of mine has tested and got the following:
"I am getting strange results like enter s nothing, enter st nothing, enter str nothing, enter stra - get drop down of titles starting with stra, enter s - get drop down of titles starting with stra, enter x get nothing, enter xa get drop down of titles starting with xa
Seems inconsistent, especially later test with x."
So, anyone else know anything. I know it's hard to fix the prob if you cant see it, but two of us see it now. Anyone??
Copy link to clipboard
Copied
cfquery name="results" datasource="#dsn#" maxrows="20"
Use your database's operators to limit the number of records returned (not "maxrows). The syntax varies by database type, but for MS SQL use the TOP operator. For MySQL use LIMIT, etcetera...
select distinct discs.artist from discs
select distinct discs.title from discs
You should really consider redesigning your tables. Storing "artist" and "title" information all in the same table, is not a good structure. For one thing, it can lead to poor query performance, because queries must use DISTINCT to eliminate the duplicate data. Performance issues will become more noticible the larger the table grows. I suspect this is at least partially responsible for some of the sluggishness I noticed earlier ..
A better structure would be to store the distinct "Artists" in one table and album "Titles" in another. If albums can be related to more than one artist, create a third table to store the relationships. That will eliminate the redundancies, and the need to use DISTINCT. (Well .. maybe. ) But the important part is that Artist _name_ should not be stored with the album "Titles". Just the unique RecordID for the artist.