Javascript: How to get selected checkbox items in a table
<p>I have a checkbox, where I am loading its inputs from a web service. I'm developing a function which filters the selected items and puts them in a table.</p>

<p>My checkbox looks like this:</p>

<pre><code>&lt;label class="checkbox" data-match-for="filtre-competences"&gt;
    &lt;input id="checkbox_competence" name="missionPlace" value="" type="checkbox" data-match-forcontent="id-competence"&gt;
    &lt;span class="check"&gt;&lt;/span&gt;
    &lt;span class="checkbox-title" data-match-forcontent="titre-competence"&gt;&lt;/span&gt;
    &lt;span&gt;(&lt;span data-match-forcontent="nb-mission"&gt;&lt;/span&gt;)&lt;/span&gt;
&lt;/label&gt;
</code></pre>

<p>I want to filter the selected elements in a table and of course deselect items which may bed deselected dynamically.</p>

<p>My function looks like this:</p>

<pre><code>selectCompetences:function () {
    var checkbox = document.querySelector('#checkbox_competence');
    var arr = new Array();
    checkbox.addEventListener('click',function () {
        if () {
            //selected : add to table
            arr.push(checkbox.getAttribute("value"))
        }
        else {
            // deselected: remove from table
        }
    })
}
</code></pre>

<p>I need to complete this function. Any suggestions?</p>