[jQuery] [autocomplete] auto complete based on additional input value

[jQuery] [autocomplete] auto complete based on additional input value


I'm using one of the examples from the demo files as a template.
Basically I'd like to auto suggest hospitals based on the zip code
that's entered from another input. Can someone recommend how do
accomplish this? TIA
This is the local data set:
var hospitals = [
{ name: "hospital 1", zip:
"00001"},
{ name: "hospital 2", zip: "00002"},
{ name: "hospital 3", zip:
"00003"},
{ name: "hospital 4", zip: "00004"},
{ name: "hospital 5", zip:
"00005"},
...
and here's the autocompleter:
<script>
$(document).ready(function(){
$("#example").autocomplete(hospitals, {
    matchContains: "word",
    max: 8,
    width: 500,
    scrollHeight: 300,
extraParams: {
return "00001";
},
    formatItem: function(row, i, max) {
        return row.name + "<em> (zip code: " + row.zip + ")</em>";
    },
    formatMatch: function(row, i, max) {
        return row.name;
    },
    formatResult: function(row) {
        return row.name;
    }
    });
});
</script>
<input id="zipcode" />
<input id="example" />