Autocomplete using jQuery

 
Many times we are having requirements to develop autocomplete functionality.
So you can use below code to get it work using jQuery: 
 
 
<script>
 $(function() {
  var availableTags = [
   "ActionScript",
   "AppleScript",
   "Asp",
   "BASIC",
   "C",
   "C++",
   "Clojure",
   "COBOL",
   "ColdFusion",
   "Erlang",
   "Fortran",
   "Groovy",
   "Haskell",
   "Java",
   "JavaScript",
   "Lisp",
   "Perl",
   "PHP",
   "Python",
   "Ruby",
   "Scala",
   "Scheme"
  ];
  $( "#tags" ).autocomplete({
   source: availableTags
  });
 });
 </script>


 
<div class="demo">

<div class="ui-widget">
 <label for="tags">Tags: </label>
 <input id="tags">
</div>

</div><!-- End demo -->



<div style="display: none;" class="demo-description">
<p>The Autocomplete widgets provides suggestions while you type into the field.</p>
<p>The datasource is a simple JavaScript array, provided to the widget using the source-option.</p>
</div><!-- End demo-description -->

No comments:

Post a Comment