jQuery Autocomplete enables users to quickly find and select from a pre-populated list of values as they type, leverage, search and filter. Autocomplete can be done with both client side data and server side. Client side means we fetch data only once then the filter will be applied on that data. Server side means as and when user types it goes to server and fetches relevant data.
Client Side Autocomplete:
Javascript:
- $(document).ready(function()
- {
- //simple javascript string array
- var availableKeywords = [
- "ActionScript",
- "BASIC",
- "C",
- "C++",
- "Erlang",
- "Fortran",
- "Groovy",
- "Haskell",
- "Java",
- "JavaScript",
- "Python",
- "Ruby",
- "Scala",
- "Scheme"];
- //Initialize autocomplete with the above array
- $("#keywords").autocomplete({
- source: availableKeywords
- });
- });
Join the conversation! Your thoughts help the community grow.