Reputation: 40348
I am using jQuery auto completer and getting the values from a jsp.When i specify some source i can use the following code to get the selected value.
$("#autocomplete").autocomplete({
source: source,
select: function (event, ui) {
alert(ui.item.value);
}
});
When i use like this
$("#query").autocomplete("list.jsp");
How i can use the select event.Thanks in advance....
Upvotes: 1
Views: 2140
Reputation: 122026
It is not the way you are thinking.source must mentioned to get the input values list from jsp.After selection of item there is no matter of source.You have to handle the select event to get the correct value.you want to know which item has been selected
$("#autocomplete").autocomplete({
source: source,
select: function (event, ui) {
var val= ui.item.value;
//Do some thing here if user selects right value
}
});
See to map source :
<script>
$(function() {
$("#jquery_from_ob").autocomplete({
source: "getblocks.jsp",
minLength: 2,
});
});
</script>
Reference:http://jqueryui.com/autocomplete/#remote
Upvotes: 1
Reputation: 862
try this:
$( "#query" ).autocomplete({
source: "list.jsp",
minLength: 2
});
Upvotes: 0