hello frank,

your application knows what's the zip of each hospital, so i think there's not 
worth sending it and expecting it back.
what you probably need is to take the zip from another field supplied by the 
user, and base the query upon it. that's extraParam for. the key part is the 
variable passed, and the value may be the value to give it, i.e. {zipfield: 
$('#zipfield').val()}.

the data you pass th the autocomplete may be a list of hospital names, or any 
other format, if you supply a parse function also.

On Fri, Sep 25, 2009 at 06:30, Frank <elun...@gmail.com> wrote:

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" />




--
alex

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to