Ok, clearly nobody knows how to define an event handler or use jQuery.
Since I don't know either, I have tried another approach.
First I created a hidden field with the name of "id_holder". I also have an input field where I want the returned value to be displayed named "id_target".
Then I changed my findValue() function to:
function findValue(li) {
if( li == null ) return alert("No match!");
if( !!li.extra ) var sValue = li.extra[0];
document.my_form.id_holder.value = sValue;
}
Now my calling function is:
function fillCodes() {
var oSuggest = $("#my_input_field")[0].autocompleter;
oSuggest.findValue();
var this_holder = eval("document.my_form.id_holder");
var this_target = eval("document.my_form.id_target")
alert(this_holder.value);
alert(this_holder.value);
this_target.value = this_holder.value
}
Now the curious thing is that the first alert is empty, while the second identical alert displays the correct id value. If the script does not contain at least one alert, then id_target remains empty.
Can anybody offer a solution as to how I can make this work without an alert? What is actually happening between the first and second alert?
If you are wondering why I don't put it all within the findValue() function, its because the final fillCodes() function will contain a loop to populate fields by sequence (the above code is simplified to make it easy to read).
Sandra