Hi Dan, guess I'll jump in real quick while the iron is hot. I too am a noob to jQuery and Ajax stuff in general. I borrowed your autocomplete example (and downloaded your recent presentation to check out the other stuff), and I have it working great, including passing the hidden id value, etc. Although I must admit I need to get more familiar with jQuery because my stuff is a mix of jQuery and js and is much more verbose at this point. But it works great on a table lookup with about 20,000 entries in it, thanks. I apologize in advance for being verbose, but I don't know how else to ask it.
At any rate, I have a couple questions regarding a form with 2 autocomplete fields which both lookup the same table. I have two different declarations going which call the same cf query: function lookupAjax(){ var oSuggest1 = $("#unit_name")[0].autocompleter; var oSuggest2 = $("#unit_lookup")[0].autocompleter; oSuggest1.findValue(); oSuggest2.findValue(); return false; } $(document).ready(function() { $("#unit_name").autocomplete("qryUnitLookup.cfm",{ options left out for brevity}); $("#unit_lookup").autocomplete("qryUnitLookup.cfm",{}); }); They both call findValue() and work great, and apparently without conflict as standalone fields. However, I am using the unit_lookup field in the second declaration to dynamically populate a select menu on the form with the selected value from that unit_lookup. So when the user selects the lookup value and presses enter, the id and value are added as a new option in the select. There is also a button to remove selected entries. Here is the modified findValue() function. function findValue(li) { if( li == null ) return alert("No match!"); // Use the unit_id as the value if( !!li.extra ) var sValue = li.extra[0]; // otherwise, let's just display the value in the text box else var sValue = li.selectValue; var elSel = document.getElementById('additional_units'); var elLookup = document.getElementById('addunit_lookup'); // this line would be replaced with a legit evaluation if (the field being evaluated is unit_lookup, execute this block) { if (elSel.options[0].text == '---------- None Selected ----------') { elSel.remove(0); } // append the selected value if (elSel.length < 25) { appendOption(sValue,li.selectValue); // blank out the search text field elLookup.value = ''; elLookup.focus(); } } } What I would like to do is identify some jQuery(?) variable that would allow me to bracket some code in the findValue() function, so that if the field value being evaluated is from unit lookup, it runs, and if it isn't it doesn't. I need to have a way to eliminate duplicate lookup selections for the select control, and I was considering looping through the select options in findValue() to see if the option existed before allowing them to add it. In other words, I would like to avoid having to create a separate instance of findValue() and maybe the other functions for each field, if there is a way to do this. I have been mucking around in Firebug and I can't find anything. Does this make sense? Know of a way to do this? Secondly, I see the dataset values returned from the ajax call in the response header using Firebug, but can't figure out a way to access them. I don't know where these go, but they don't appear to be in the DOM. I was trying to come up with a way to loop through the query result values and compare them against the previous options already added to the select menu, and not allow them to display in the unit_lookup list if they already exist. Don't know if this is possible or not. Jeff