I want to get data from database to text field by using autopopulate when i type data in text field using javascript can any one help to me please
Asked
Active
Viewed 1,357 times
0
-
are you using particular server side technologies, and particular client side frameworks, or you open to everything ? – vittore Mar 17 '13 at 20:34
1 Answers
0
One of the way to solve that is for instance to use autocomplete control from jquery.ui and create service using language/server of your choose to get data from your db.
Configuring jquery.ui autocomplete is as simple as
var availableOptions = ["apple", "pear", "pineapple"]
$( "#auto" ).autocomplete({
source: availableOptions
});
just having input control
<div>
<label for="auto">Fruits: </label>
<input id="auto" />
</div>
So if you dont have thousands of data items above is one of the easiest ways.
Alternatively, having implemented web service you can query it ajax-style, configuring autocomplete plugin right way
$('#auto').autocomplete({
source: function( request, response ) {
$.getJSON( "/api/search", {
term: request.term
}, response );
},
search: function() {
var term = this.value
if ( term.length < 2 ) {
return false;
}
}
})

vittore
- 17,449
- 6
- 44
- 82