Skip to content

Instantly share code, notes, and snippets.

@albertoperdomo
Created July 6, 2010 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save albertoperdomo/465262 to your computer and use it in GitHub Desktop.
Save albertoperdomo/465262 to your computer and use it in GitHub Desktop.
$(function(){
$("select#search_country_id").change(function(){
$("img#spinner_city_id").show();
$("select#search_city_id").disable();
$.getJSON("/cities.json",{country_id: $(this).val(), ajax: 'true'}, function(j){
var options = '';
for (var i = 0; i < j.length; i++) {
options += '<option value="' + j[i]["city"]["id"] + '">' + j[i]["city"]["name"] + '</option>';
}
$("select#search_city_id").html(options);
$("select#search_city_id").enable();
$("img#spinner_city_id").hide();
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment