Hi, I have the code below on my page. The bindBehaviours function is used as the page is loaded via an AJAX call in a jQuery UI Tab. I want the autocomplete to check the value is in the list and to add the engineerID to a hidden field based on the EngineerName selected in the autocomplete box. The EngineerID is returned with the Name from s_engineer_list.php. The code to set the EngineerID is not present below I just want to see the results working in the alerts before adding this bit of the code.
I was using the following code but this only works if the item in the autocomplete dropdown is clicked on or if selected by cursor and then the enter key pressed. It doesn't work if the data is "auto-filled" and then the focus moved to the next input box. $("#EngineerName", scope).result(function(event, data, formatted) { if (data) $("#EngineerID", scope).val(data[1]); }); Thanks for your help, Adam PAGE CODE STARTS HERE var bindBehaviors = function(scope) { $("#EngineerName", scope).autocomplete("s_engineer_list.php", { onItemSelect: selectItem, onFindValue: findValue, autoFill: true, selectFirst: false }); } bindBehaviors(this); function selectItem(li) { findValue(li); } function findValue(li) { if( li == null ) return alert("No match!"); if( !!li.extra ){ var sValue = li.extra[0]; } else{ var sValue = li.selectValue; } alert("The value you selected was: " + sValue); }