Introduction
AutoSuggeation shows a small window like a popup panel to the display words of the prefix typed into the TextBox. For example a country text box, that will fill in the entry India when the first letter is typed, then displays a suggestion list like a popup panel.
In this article I will explain how to create an AutoSuggestion by default in jQuery.
Complete Program
AutoSuggestion_Demo.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>AutoSuggestion in jQuery - Default functionality</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
<script src="jquery-1.9.1.js"></script>
<script src="jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function () {
var CountryName = [
"Australia",
"Austria",
"Azerbaijan",
"Bahamas",
"Bangladesh",
"Canada",
"China",
"Czech Republic",
"Denmark",
"Egypt",
"El Salvador",
"French Southern Territorie",
"Germany",
"Guatemala",
"Hong Kong",
"Hungary",
"Iceland",
"India",
"Indonesia",
"Iran, Islamic Republic Of",
"Jamaica",
"Kenya",
"Liberia",
"Luxembourg",
"Macao",
"Nepal",
"Islands",
"Norway",
"Oman",
"Pakistan",
"Rwanda",
"Sri Lanka",
"United Kingdom",
"United States"
];
$("#name").autocomplete({
source: CountryName
});
});
</script>
</head>
<body>
<div class="ui-widget">
<label for="tags">CountryName: </label>
<input id="name" />
</div>
</body>
</html>
Output

For more information, download the attached sample application.


Dammy SubayrPosted Oct 29, 2014, 5:34 AM EDT
what if I want to populate the suggestions from db?
Nitin BhardwajPosted Mar 14, 2013, 1:45 AM EDT
You can download the attached sample application.
gks bvlPosted Mar 13, 2013, 6:08 AM EDT
Thanks for the example. It really helped me. Can you please send the style.css file (mentioned in <link rel="stylesheet" href="/resources/demos/style.css" />) Thanks!