I\'ve been trying to figure out how to submit the form when the person selects the result from choices of the autocomplete. It needs to work with a mouse click or enter butt
Actually, you don't need to target the for element and form by ID... since that information is already passed to the select function via the Event object. It's better to get the form this way because you may have multiple forms on a page that you want to apply autocomplete to. Or you may want autocomplete on multiple elements.
Also, the syntax in the other answer is wrong. JQuery uses .val() not .value() to set an input's value.
Here's a corrected example:
$("#vsearch").autocomplete({
source: "ajax/search.php",
minLength: 2,
select: function(event, ui) {
//assign value back to the form element
if(ui.item){
$(event.target).val(ui.item.value);
}
//submit the form
$(event.target.form).submit();
}
});