jjj
jjj

Reputation: 1005

Auto submit form when value from input text is selected (autocomplete)

I would like to auto submit a form when a value from the autocomplete input text is selected.

I'm actually trying something like this but it auto submit each time the text is filled.

$('input.text').on('keyup', function() { 
    $('form').submit();
});

Thanks

Upvotes: 0

Views: 1345

Answers (1)

Pawan
Pawan

Reputation: 1744

You can use below code from http://api.jqueryui.com/autocomplete/#event-select :

$("#searchField").autocomplete({
     source: "values.json",
     minLength: 2,
     select: function(event, ui) { 
     $("#searchField").val(ui.item.value);
     $("#form").submit(); }
});

Upvotes: 1

Related Questions