Last active
July 26, 2020 11:41
-
-
Save surferxo3/0b3825300a28d6eaebeb3f617f3f3153 to your computer and use it in GitHub Desktop.
Select / Deselect All Checkboxes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// change selection_all checkbox state | |
$("[name=\'selection[]\']").change(function() { | |
var state = true; | |
if ($("[name=\'selection[]\']:checked").length != $("[name=\'selection[]\']").length) { | |
state = false; | |
} else { | |
state = true; | |
} | |
$("[name=\'selection_all\']").prop("checked", state); | |
}); | |
// change selection[] checkboxes state | |
$("[name=\'selection_all\']").change(function() { | |
$("[name=\'selection[]\']").prop("checked", $(this).is(":checked")); | |
}); | |
// get checked selection[] checboxes as string | |
$("#w0").submit(function() { | |
var checkedIds = $("[name=\'selection[]\']:checked").map(function() { | |
return $(this).val(); | |
}).get().join(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment