I’ve followed the tutorial at this site: http://thedrupalblog.com/creating-autocomplete-field-using-forms-api-and-menu-callback and have my autocomplete working great.
What I’m not sure how to do and can’t seem to find online is have the form submit when a user clicks a suggestion instead of simply completing that field.
Thanks in advance.
This may not be the best “drupal” way to do it, maybe someone can improve it…
in your ‘misc/autocomplete.js’ file find:
and change it to :
then on your form item add:
That will cause the form to submit regardless of how the user chooses to select (enter button or mouse click)
EDIT: 4 years later I got a vote up and realized this needs to be updated…basically @Azhar is right, rather than editing the existing file, this code should be added to a new JS file that loads after autocomplete.js.
As is true any time you edit the core you run into having to worry about core security updates which would override your change and leave your site broken and you scrambling to fix it again.