Futuregeek
Futuregeek

Reputation: 1980

Check chekbox while selecting fdropdown

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

Answers (1)

user5116395
user5116395

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);
});

http://jsfiddle.net/NEESR/

Upvotes: 1

Related Questions