Few observations
- You need to listen to input using the class
adminBox, not to all the checkboxes - Use the checked property to check if it is checked.
adminBox is not a class name- use .val () to set the value of the select element
It should be
$("input.adminBox").change(function () {
if (this.checked){
$("#role").val('admin');
} else {
$("#role").val('sei');
}
});
Demo: Fiddle
source
share