multiple checkboxes ctrl shift - Free Download Select Multiple Checkboxes With Ctrl and Shift Keys

Free Download Select Multiple Checkboxes With Ctrl and Shift Keys

Posted on

This time I will share jQuery Plugin and tutorial about Select Multiple Checkboxes With Ctrl and Shift Keys, hope it will help you in programming stack.

multiple checkboxes ctrl shift - Free Download Select Multiple Checkboxes With Ctrl and Shift Keys
File Size: 245 KB
Views Total: 1683
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

A small jQuery plugin for multi-select checkboxes that enables the user to check all related checkboxes with one click and/or select multiple checkboxes with CTRL and Shift keys.

Useful in cases where you want to select multiple rows/items in an HTML table/list.

How to use it:

1. Create a group of checkboxes on the web page.

1 <input type="checkbox" class="select-checkbox" value="1" />
2 <input type="checkbox" class="select-checkbox" value="2" />
3 <input type="checkbox" class="select-checkbox" value="3" />
4 <input type="checkbox" class="select-checkbox" value="4" />
5 <input type="checkbox" class="select-checkbox" value="5" />
6 ...

2. Create a ‘Parent’ checkbox to check/uncheck all these checkboxes.

1 <input type="checkbox" class="select-all-checkbox" value="1" />

3. Load the multiselect-checkbox plugin after loading the latest jQuery library.

1 <script src="/path/to/cdn/jquery.min.js"></script>
2 <!-- From Local -->
3 <script src="/path/to/dist/jquery-multiselect-checkbox.js"></script>
4 <!-- Or From A CDN -->

4. Synchronize the selection events to your elements, e.g. table rows:

1 $(".select-all-checkbox").multiselectCheckbox({
2   checkboxes: ".select-checkbox",
3   sync: ".table .row"
4 });

5. The you can customize the selected rows in the CSS.

1 tr.jquery-multi-select-checkbox-checked {
2   background: #ebf9ff;
3 }

6. Callback functions.

01 $(".select-all-checkbox").multiselectCheckbox({
02   checkboxes: ".select-checkbox",
03   sync: ".table .row",
04   onNotAllChecked: function(selectedMap) {
05     console.log("Not all checked", selectedMap.orderedByI());
06   },
07   onAllChecked: function(selectedMap) {
08     console.log("All checked", selectedMap.orderedByI());
09   },
10   onAllUnchecked: function(selectedMap) {
11     console.log("All unchecked", selectedMap.orderedByI());
12   }
13 });

7. All default options.

01 $(".select-all-checkbox").multiselectCheckbox({
02   checkboxes: null,
03   sync: null,
04   onAllChecked: () => {},
05   onAllUnchecked: () => {},
06   onNotAllChecked: () => {},
07   eventsElement: document,
08   syncEvent: "click",
09   handleShiftForCheckbox: false,
10   usePrevUntilNextUntilForSync: true,
11   checkedClassName: "jquery-multi-select-checkbox-checked",
12   checkedKeyDataAttributeName: "jquery-multi-select-checkbox-checked-key"
13 });

This awesome jQuery plugin is developed by tonix-tuft. For more Advanced Usages, please check the demo page or visit the official website.