I have two HTML select boxes. I need to reset one select box when I make a selection in another.
I had a problem using the defaultSelected property in the answer by @Jens Roland in jQuery v1.9.1. A more generic way (with many dependent selects) would be to put a data-default attribute in your dependent selects and then iterate through them when reseting.
And the javascript...
$('#name0').change(function(){
if($('#name0').val() == '') {
$('select.name').each(function(index){
$(this).val($(this).data('default'))
})
} else {
$('select.name').val($('#name0').val() );
}
});
See http://jsfiddle.net/8hvqN/ for a working version of the above.