1

I would like to use Autocomplete script from jquery-ui.min.js. So in code I have:

<select id="country"><option value="">Choice one</option>
<option value="1">US</option>
<option value="2">UK</option></select>
<input type="text" id="city" >

And the script:

<script>
$(function() {
  var US= ["City1", "City2", "City3"];
  var UK= ["UK_City1", "UK_City2", "UK_City3"];
  $("#city").autocomplete({  
  source: US  
  });
}); 
</script>

The question is how to change source dependent on user selected text from Select ID="Country"? Here is also this script: http://jsbin.com/adopo3/35/edit

Lucas
  • 2,784
  • 6
  • 25
  • 32

1 Answers1

0

Simplest way is to use option method to change the source. I have modified your example code to illustrate it here.

Another way would be to supply callback function to the source option. See that here

VinayC
  • 44,892
  • 5
  • 56
  • 69
  • This is working fine, but what to do if I have more than two options in my Select, eg.`` and more vars? – Lucas Nov 03 '11 at 11:45