Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This works using your demo:</p> <pre><code>&lt;script type="text/javascript"&gt; var allId = 'all'; function getCheckboxes() { return document.getElementById('checkboxes').getElementsByTagName('input'); } function clearCheckboxes() { var checkboxes = getCheckboxes(); for(var i=0; i&lt;checkboxes.length; i++) { if (checkboxes[i].id != allId) { checkboxes[i].checked = false; } } } function setCheckboxes() { var allCheckbox = document.getElementById(allId); var checkboxes = getCheckboxes(); var allChecked = true; for(var i=0; i&lt;checkboxes.length; i++) { if (checkboxes[i].id != allId) { if (!checkboxes[i].checked) { allChecked = false; } } } if (!allChecked) { allCheckbox.checked = false; } else { allCheckbox.checked = true; clearCheckboxes(); } } &lt;/script&gt; &lt;div id="checkboxes"&gt; &lt;label&gt; &lt;input onclick="clearCheckboxes();" type="checkbox" name="rb" value="all" id="all" checked&gt; All&lt;/label&gt; &lt;label&gt; &lt;input onclick="setCheckboxes();" type="checkbox" name="rb" value="ln" id="ln"&gt; Option 1&lt;/label&gt; &lt;label&gt; &lt;input onclick="setCheckboxes();" type="checkbox" name="rb" value="prodsandserv" id="prodsandserv"&gt; Option 2&lt;/label&gt; &lt;label&gt; &lt;input onclick="setCheckboxes();" type="checkbox" name="rb" value="publications" id="publications"&gt; Option 3&lt;/label&gt; &lt;label&gt; &lt;input onclick="setCheckboxes();" type="checkbox" name="rb" value="comm" id="comm"&gt; Option 4&lt;/label&gt; &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload