Quantcast
Channel: Topliners: Message List
Viewing all articles
Browse latest Browse all 3737

Re: How do I pre-populate checkboxes based on a picklist selection?

$
0
0

Hey Jorge,

 

This is the basic idea, I just copy/pasted/wrote really quick, so better check it.

 

When select is the multiselect and myCheckbox is the theckbox....

 

$(document).ready(function() {

    $( "select" ).change(function () {

        $( "select option:selected" ).each(function() {

            /*do something here to make the checkbox logic and check the box using this: */

            $('.myCheckbox').prop('checked', true);

});})});

 

Reference

1) :checkbox Selector | jQuery API Documentation

2) .change() | jQuery API Documentation<--- Check the demo at the bottom here

 

 

So the mapping would be, if they click on option A, checkbox 1 &2 get checked, if they click on option B, checkbox 1 & 3 get checked..... and so forth. The mapping would be manual.

 

Also you have to consider unchecking the boxes, which is also covered in ref 1.


Viewing all articles
Browse latest Browse all 3737

Trending Articles