summaryrefslogtreecommitdiff
path: root/elm/checkall.js
diff options
context:
space:
mode:
Diffstat (limited to 'elm/checkall.js')
-rw-r--r--elm/checkall.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/elm/checkall.js b/elm/checkall.js
new file mode 100644
index 00000000..4343ffc8
--- /dev/null
+++ b/elm/checkall.js
@@ -0,0 +1,16 @@
+/* "checkall" checkbox, usage:
+ *
+ * <input type="checkbox" class="checkall" name="$somename">
+ *
+ * Checking that will synchronize all other checkboxes with name="$somename".
+ */
+document.querySelectorAll('input[type=checkbox].checkall').forEach(function(el) {
+ el.onclick = function() {
+ document.querySelectorAll('input[type=checkbox][name="'+el.name+'"]').forEach(function(el2) {
+ if(!el2.classList.contains('hidden')) {
+ if(el2.checked != el.checked)
+ el2.click();
+ }
+ });
+ };
+});