As a follow on my from last post – How would I trim the input to a JQuery auto-complete box? . I decided to make a new question rather than to continue editing that one.
I currently have jQuery ui autocomplete 1.8 (or so) working reasonably well, except from one thing. If the user just enters a (valid) name and hits submit, the auto-complete lookup never runs, and so the associated value is never grapped and assigned to the input box. This, of course, is a problem. Reading the documentation, it implies that I could use the jQuery search() method to over-come this. However, I am struggling to get it to work. I have tried both putting the call to search() in the onblur event of the text input, and in the onclick event of the submit button, but to no avail – whenever I hit submit I have no value for the input box. The code:
<form action = "<?php echo $this->URL();?>" method="post">
<fieldset>
<ol>
<li>
<label for="Resource">Resource</label>
<input id="Resource" name="Resource" class="text" type="text" value="" onblur="jQuery('#Resource').search();"/>
</li>
</ol>
</fieldset>
<fieldset class="submit">
<input id="Submit" name="Submit" type="Submit" class="Submit" value ="Submit" onclick = "jQuery('#Resource').search();"/>
</fieldset>
</form>
So, what exactly am I doing wrong?
You need to add the automated-choose-any-matching-result code in the change event.
Check my answer on your other question:
jQuery autocomplete problem – doesn't match if user doesn't specifically select