I have a select input:
<select size="1" name="filter" style="width:90px;" id="priority_filter" onchange="filter_user_trainings();">
<option value="all">All</option>
<option value="optional">Optional</option>
<option value="mandatory">Mandatory</option>
<option value="essential">Essential</option>
<option value="custom">Custom</option>
</select>
<div style="width: 50%; text-align: right; float: right">
<input type="checkbox" id="opt_box" onchange="somestuff()">Optional
<input type="checkbox" id="mand_box" onchange="somestuff()" checked="checked">Mandatory
<input type="checkbox" id="ess_box" onchange="somestuff()">Essential
</div>
And a jQuery code:
switch(priority_filter){
case 'all':
$("#opt_box").attr({checked: "checked"});
$("#mand_box").attr({checked: "checked"});
$("#ess_box").attr({checked: "checked"});
break;
case 'optional' :
$("#opt_box").attr({checked: "checked"});
$("#mand_box").removeAttr("checked");
$("#ess_box").removeAttr("checked");
break;
case 'essential' :
$("#ess_box").attr({checked: "checked"});
$("#mand_box").removeAttr("checked");
$("#opt_box").removeAttr("checked");
break;
case 'mandatory' :
$("#mand_box").attr({checked: "checked"});
$("#opt_box").removeAttr("checked");
$("#ess_box").removeAttr("checked");
case 'custom' :
$("#mand_box").attr({checked: "checked"});
$("#opt_box").removeAttr("checked");
$("#ess_box").removeAttr("checked");
break;
}
I want to call the function in the "onchange" attr. when the js switch the checkboxes' values but it does not works. How can I fix it?