Created
October 31, 2011 12:51
-
-
Save mphalliday/1327432 to your computer and use it in GitHub Desktop.
Dependent jquery select lists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".country_selector").change( function(){ | |
if ($(".region_selector").length > 0){ | |
$.getJSON('/countries/'+$(this).val(), function(data) { | |
$(".region_selector").html($("<option></option>")); | |
$.each(data.country.regions, function(index, region){ | |
$(".region_selector"). | |
append($("<option></option>"). | |
attr("value",region.id). | |
text(region.name)); | |
}); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment