9 examples of 'checkbox select all' in JavaScript

Every line of 'checkbox select all' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
18function updateSelected(checkbox) {
19 var newList = updateChecks(checkbox);
20 setWbsIdList(newList);
21}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

1function toggle_select_all() {
2 $('#users ul').find('input').each(
3 function(){
4 if(!$(this).attr("checked")) {
5 $(this).attr("checked",true);
6 } else {
7 $(this).attr("checked",false);
8 }
9 }
10 );
11}
18_toggleSelectAll(c, checked) {
19 if (checked) {
20 this.set('languages', ['Javascript', 'C++', 'PHP']);
21 } else {
22 this.set('languages', []);
23 }
24}
45get allSelected(): boolean {
46 return this._isAllSelected;
47}
60selectAll(checked) {
61 this.props.setChecked(
62 (checked &&
63 this.props.contentList.map(({ attributes: { nid } }) => nid).reduce(
64 (acc, cur) => ({
65 ...acc,
66 [cur]: true,
67 }),
68 {},
69 )) ||
70 {},
71 );
72}
448function selectAllCheckboxes(select, ctx) {
449 var inputs = container.getElementsByTagName('input');
450 for (var i = 0; i < inputs.length; i++) {
451 var input = inputs[i];
452 if (input.type !== 'checkbox') continue;
453 input.checked = select;
454 input.indeterminate = false;
455 }
456 ctx._onInputClick();
457}
55onAllChecked() {
56 this.data.forEach(item => (item.checked = this.allChecked));
57 this.notifySet();
58}
76function SelectAllButton() {
77 const allSelected = checkListOptions.every(option => isChecked(option.value));
78 const anchorClassName = `btn btn-default btn-xs ${inline ? '' : 'push-left'}`;
79 const style = inline ? { margin: '8px 0 0 10px' } : {};
80
81 const selectValue = (selected: string[]) => {
82 return onChange(createFakeReactSyntheticEvent({ name: props.name, value: selected }));
83 };
84 const selectNone = () => selectValue([]);
85 const selectAll = () => selectValue(checkListOptions.map(o => o.value));
86
87 return (
88 <a className={anchorClassName} style={style} type="button" onClick={allSelected ? selectNone : selectAll}>
89 {allSelected ? 'Deselect All' : 'Select All'}
90 </a>
91 );
92}
212function updateCheckbox() {
213 $('#charts input, #components input, #coords input').each(function () {
214 $(this).attr('checked', $(this).parent().hasClass('checked'));
215 });
216}

Related snippets