We help IT Professionals succeed at work.

Customizing Coldfusion Autosuggestive Outputs

SFTProd
SFTProd asked
on
Medium Priority
345 Views
Last Modified: 2012-06-27
I am trying to customize what results the autosuggested value shows but am not having much luck other than it showing everything that starts with what is in the form field.

I want it to work like the following example where I can enter a string that is not necessarily the starting part of the string and it would suggest all strings that match the string typed in as a sub-string.

http://www.nodans.com/custom/examples/cf9/CustomAutosuggest/

Thanks in advance.
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
Is your source a CFC or a javascript function?

Author

Commented:
The source is a cfc.  For some reason, it has a tendency of only showing results that match stuff already typed into the form field at the beginning.  This happens no matter what data is returned by the CFC.
CERTIFIED EXPERT
Most Valuable Expert 2015
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
I am getting the error message "setFilter is not defined."
CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
I tested it successfully w/CF9.  Are you running just the snippet posted or did you add the code to a larger form?

Author

Commented:
I took the following and put it in my header file between the head tags.  Once the page loads, I get the error.

<script type="text/javascript">
  var setFilter = function(){
  var lang = ColdFusion.objectCache[ 'language' ];
  lang.queryMatchContains = true;
  };      
</script>

<cfset ajaxOnLoad("setFilter")>
CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
Yeah, when I tested it CF was a bit picky about where the script tags where placed.  Try the sample code independently first.  If it works correctly, then it's probably something about the placement of the <script> it doesn't like.
CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
It works solo. So the problem is definitely the internal voodoo CF uses when placing it's auto generated code. If you're still having problems with it, just post your actual form code.

http://www.dansshorts.com/post/ajaxonloafd-and-cfhtmlhead


Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.