Reputation: 131058
Auto-complete seems to be a standard tool on web sites. Surprisingly, it is hard to find a ready-to-use solution in Internet. I have some basic requirements to the code:
Do I want to much or there is something in the Internet?
ADDED:
As the first answer suggest, there is a solution provided by JQuery. I have managed to make it work. However it was not trivial, since the code is given out of the context. First it is not clear where I need to put this code (head?, body?). Then if I put it in the body it start to work only after I put this stuff to the head:
<link rel="stylesheet" href="/css/base.css" type="text/css" media="all" />
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/themes/base/jquery-ui.css" type="text/css" media="all" />
<link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" media="all" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js" type="text/javascript"></script>
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/external/jquery.bgiframe-2.1.2.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/i18n/jquery-ui-i18n.min.js" type="text/javascript"></script>
<script src="/js/demos.js" type="text/javascript"></script>
<script src="/themeroller/themeswitchertool/" type="text/javascript"></script>
It was not written on the page that I need to use this lines to make the code work. I copied this lines from the head of the page that provide the example of the auto-complete.
Moreover, I still have the problem since the auto-complete search all the words that contain the typed substring (and I need the words that start from the typed substring).
Upvotes: 1
Views: 5010
Reputation: 272106
How about this demo:
Moreover, I still have the problem since the auto-complete search all the words that contain the typed substring (and I need the words that start from the typed substring).
For this you need to implement your own implementation of the source parameter. Documentation says that you can specify the following as the source:
Now that you say that you want the suggested words to come from a server, you should use the second option (specify a URL for JSONP). That allows you to handle "I need the words that start from the typed substring" part.
Upvotes: 1
Reputation: 235992
If jQuery is an option as library, the UI plugin offers a great autocomplete.
Upvotes: 2