Solved

Coldfusion Powered Bootstrap Typeahead

Posted on 2013-12-09
5
908 Views
Last Modified: 2013-12-12
Since I can't use coldfusion "autosuggest" with Railo, I need help in getting this to work with bootstrap typeahead and any help is appreciated!

The following is example code that works but is not dynamic. I need to integrate the query below.

------------------
<input
                    type="text"
                    class="span4 basicTypeahead"
                    placeholder="What's your favorite US State?"
                    autocomplete="off"
                    data-provide="typeahead"
                />

Open in new window


How can I get the results of a cfquery to populate the bootstrap typeahead? Code examples appreciated!
 <script type="text/javascript">
        var dataset = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'District of Columbia', 'Florida'];
        $(function(){
            $(".basicTypeahead").typeahead({
                source: dataset
                ,items: 10
            });
        });
    </script>

Open in new window



My query

      <cfquery datasource="myds" name="data">
            SELECT ID
            FROM res
            WHERE Trim(ID) LIKE Trim('#ARGUMENTS.search#%')
            ORDER BY ID
      </cfquery>
0
Comment
Question by:Bang-O-Matic
  • 2
  • 2
5 Comments
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
could you provide a link to a simple test page
0
 

Author Comment

by:Bang-O-Matic
Comment Utility
Hi leakim971,

Here is a link to test page    http://macongahomes.com/test2.cfm

Thanks for your help!
0
 
LVL 15

Expert Comment

by:myselfrandhawa
Comment Utility
in your dataset, store the results of the query using a valuelist function, it will give you comma separated values and then you can use them
0
 
LVL 15

Accepted Solution

by:
myselfrandhawa earned 500 total points
Comment Utility
Like this

 var dataset = [<cfoutput>#quotedValueList(myquery.ciitiesName)#</cfoutput>];
0
 

Author Closing Comment

by:Bang-O-Matic
Comment Utility
Works Perfectly! Thank you!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

772 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

14 Experts available now in Live!

Get 1:1 Help Now