Skip to content

Instantly share code, notes, and snippets.

@nclundsten
Created June 24, 2013 22:01
Show Gist options
  • Save nclundsten/5854029 to your computer and use it in GitHub Desktop.
Save nclundsten/5854029 to your computer and use it in GitHub Desktop.
function filterProvinces(element, countryCode) {
$(element).val(0);
$(element).find('optgroup').remove();
options = $(element).data('options');
//need to get the maching option by countrycode (id)
//$(element).append(html);
}
$(document).ready(function(){
province = $("select[name=province]");
opts = $(province).find('optgroup'); //get the opts as a var
$(province).data('options', $(opts)); //store as data
$(province).find('optgroup').remove(); //remove the elements
$("select[name=country]").live('change', function() {
province = $(this).siblings("select[name=province]");
val = $(this).val();
filterProvinces(province, val)
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment