1

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....

4

2 回答 2

1

这不是您的想法。必须提到源才能从 jsp 获取输入值列表。选择项目后,无论源是什么。您必须处理选择事件才能获得正确的值。您想知道哪个项目已被选中

 $("#autocomplete").autocomplete({
        source: source,
        select: function (event, ui) {
             var val= ui.item.value;
             //Do some thing  here if user selects right value 
        }
    }); 

请参阅地图来源:

<script>
$(function() {
    $("#jquery_from_ob").autocomplete({
        source: "getblocks.jsp",
        minLength: 2,
    });
});
</script>

参考:http: //jqueryui.com/autocomplete/#remote

于 2013-06-14T05:03:57.057 回答
0

尝试这个:

 $( "#query" ).autocomplete({
           source: "list.jsp",
           minLength: 2
 });
于 2013-06-14T05:09:44.480 回答