Search code examples
ajaxcoldfusionautosuggest

How to add search functionality to an AJAX-driven auto-suggest search field


I'm using he following code the call a CFC which returns auto-suggest results through AJAX.

<cfinput type="text" class="titleSearchField" name="TitleName"
autosuggest="cfc:gz.cfcomp.search.AutoSuggestSearch({cfautosuggestvalue})">

What this does right now is only generate an Auto-suggest list. Clicking on one of the auto-generated results does nothing, but retain it in the input field. How do I make the search form visit a results page when clicked? Do I have to use the onClick attribute and pass the results for an additional query to full process the result?

At suggestion below I added the following:

action="search.cfm?GameID=#AutoSuggestSearch.GameID#"

But it's throwing an error that GameID is not defined in AutoSuggestSearch (although I am selecting it from in the CFC query).


Solution

  • Did you try using onChange on the cfinput? That way when you select the value, you can fire off a form post (or another ajax request) to do a search.