Using ui autocomplete as a dropdown, with type in
I had been using an autocomplete plugin by bassistance. 2 months later jQuery UI added autocomplete to their list of widgets. Like many plugins out there I was unable to find an autocomplete that was easy to use for my purposes. The closest I recently came to was the sexy combo plugin. I cant remember why but it was just a tad short of what I wanted to do, and I’m still quite a javascript novice.
I came up with a way to use the jQuery UI autocomplete widget as a <select> that you could also type in something if the choices in the dropdown didn’t fit your needs.

This example uses a local data source, but you can come up with creative ways to use remote JSON sources if you like.
<script type="text/javascript">
$(document).ready(function() {
// dropdown/ auto suggest
$(".ui_dropdown").autocomplete({
minLength: 0,
delay: 0
});
$(".ui_dropdown").click(function(){
var input = $(this);
var inputID = input.attr('id');
// close if already visible
if (input.autocomplete("widget").is(":visible")) {
input.autocomplete("close");
return false;
}
// set source(s)
var myData = '';
if(inputID == 'input1'){
myData = ["foo","bar","hello","world"];
} else {
myData = ["1","2","3","4"];
}
// load source
input.autocomplete({
source: myData
});
// fire search event
input.autocomplete("search", "");
input.focus();
return false;
});
});
</script>
In this script I am using the input id’s to define the data source.
Great information was shared in this post…
Thank you for the post..
So glad they finally rolled this into the core jquery UI. Nice tutorial – just what i was looking for.
Thumbs up! You did have a nice tutorial there and I find it informative and so easy to follow. I am going to try it. Thanks!
Great information this is excatly what I have been looking for. Thanks heaps
Mono Bluetooth Wireless Handfree Headset Headphone N909.N909 Mono Bluetooth Wireless Handfree Headset
SX-945 Handfree Stereo Bluetooth Headset
celluless vacuum
ceramic led
chopper cute
Up to 6 hours talk time and 8 days standby time
Status Display makes it easy to check battery level and Bluetooth connectivity at a glance
Touch volume control, answer/end button, voice dialing (depending on the phone used)
Streams music from A2DP-enabled mobile phones
Connect two Bluetooth enabled devices at the same time with Multiuse capabilities Stainless Survival Tool
i am facing the problem in this step… but after reading this article i solved my problem… thnaks for sharing thios information..
I learn a lot from this post,thank you!
Nice, just to let you know the post isnt showing up properly on my iphone – I think there is a plugin you can grab that takes care of that now.
Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.
This is such a great resource that you are providing and you give it away for free. I love seeing websites that understand the value of providing a quality resource
THANKYO
air max 90
Aw, this was a really quality post. In theory I’d like to write like this too – taking time and real effort to make a good article… but what can I say… I procrastinate alot and never seem to get something done.
I found very useful and interesting posts in this blog which is the great signs for a good blogger.
Congratulation for the great post. Those who come to read your article will find lots of helpful and informative tips.
Nice post with awesome points! Can’t wait for the next one.
Nice post with loving snapshot. I am completely impressed! Keep stuff like this coming
Very nice post even i would say that whole blog is awesome. I keep learning new things every day from post like these. Good stuff!