There is a #filter div which holds the 3 selects: #dpmt_filter, #area_filter and #moi_filter. I cannot get it to "reset" the other 2 select boxes (ignoring current select box) to the "All" option (which is the top option). I thought it would be something like:
$('#filters :input').not($(this)).val('all');
but it did not work. Any idea how I can reach the other select boxes and ignore the current?
jQuery(document).ready(function($){
$('#courses_listing div.accordion').addClass('active');
$('#filter :input').change(function(){
var current_value = $(this).val();
//$('#filters :input').not(current_value).val('all');
if(current_value=="all")
{
$('#courses_listing p').remove('.no-courses');
$('#courses_listing div.accordion').removeClass('hidden').addClass('active');
$('#filters :input').val('all');
}
else
{
if ($('#courses_listing').find('.accordion').hasClass('hidden')){
$('#courses_listing').find('.accordion').not('.' + $(this).val()).removeClass('active').addClass('hidden'); // changes other values from active to hidden.
$('#courses_listing').find('.accordion' + '.' + current_value).removeClass('hidden').addClass('active'); // changes selected value from hidden to active.
} else if ($('#courses_listing').find('.accordion').hasClass('active')){
$('#courses_listing').find('.accordion').not('.' + $(this).val()).removeClass('active').addClass('hidden'); // changes selected value from active to hidden.
}
if (!$('#courses_listing div.accordion').hasClass('active')) {$('#courses_listing div#filters').after('<p class="no-courses">There are no courses with the current filter.</p>');}
else{$('#courses_listing p').remove('.no-courses');}
}});
});
Just to add, here is an example of one select box inside the #filters div:
<div id="filters">
<div id="dpmt_filter">
<p>Select box 1</p>
<form action="<?php bloginfo('url'); echo $_SERVER["REQUEST_URI"]; ?>" method="get">
<?php // Grabs Department terms and displays them
$dpmts = get_terms('departments', array(
'orderby' => 'name',
'hide_empty' => 0
) );
?>
<select id="departments">
<option value="all">All</option>
<?php foreach ($dpmts as $dpmt) : ?>
<option value="<?php echo $dpmt->slug; ?>"><?php echo $dpmt->name; ?></option>
<?php endforeach; ?>
</select>
</form>
</div>
</div>