 <p>Firstly, you'd need unique identifiers for all of your input fields, hidden or not. Then assigning values to them would be a lot easier. You're really close, and I'd only change a few things to get it working, mostly to do with the IDs of the elements you're using:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $('.auto').autocomplete({ source: "search.php", ... select: function(event, ui) { // figure out which auto we're using and get it's // associated hidden field... var element_id = $(this).attr('id'); var hidden_element_id = element_id + "_hidden"; // set the appropriate fields' values... $(this).val(ui.item.label); $("#"+hidden_element_id).val(ui.item.value); return false; } ... }); }); &lt;/script&gt; &lt;p&gt;Type the name of a band: &lt;input type="text" class="auto" id="auto1" /&gt;&lt;/p&gt; &lt;p&gt;Type the name of a band: &lt;input type="text" class="auto" id="auto2" /&gt;&lt;/p&gt; &lt;input name="hidden" id="auto1_hidden" type="hidden" /&gt; &lt;input name="hidden" id="auto2_hidden" type="hidden" /&gt; </code></pre> <p>One of the easier ways to associate hidden fields with visible counterparts...you get the ID of the element that's currently being autofilled, then grab its hidden field counterpart by just appending '_hidden' onto its ID attribute...make sense?</p> <p>Don't forget to change the ID attributes of the fields! Hope this helps!</p>