Reputation: 1980
I have a dropdown list and check box in 2 columns of table and I want to change state of checkbox by updating the dropdown.
Upvotes: 0
Views: 39
Reputation:
Set the "class" of the checkboxes to the option values. Then you can use jQuery like this:
$("select[name='types']").change(function() {
// Get the value selected (convert spaces to underscores for class selection)
var value = $(this).val().replace(' ', '_');
// Clear checks, then check boxes that have class "value"
$(":checkbox").prop("checked",false).filter("."+value).prop("checked",true);
});
Upvotes: 1