How to create/update an array using input checkboxes
<p>In my view I am iterating through a collection of <code>Customers</code> called <code>@colleagues</code> and displaying them in a list as checkbox inputs like so:</p>

<pre><code>&lt;ol&gt;
  &lt;% @colleagues.each do |c|%&gt;
    &lt;li&gt;
       &lt;input type="checkbox"&gt;
           &lt;%= c.full_name %&gt;
           &lt;%= c.id %&gt;
       &lt;/input&gt;
    &lt;/li&gt;
  &lt;% end %&gt;
&lt;/ol&gt;
</code></pre>

<p>What I wish to do is collect each checked/selected name in an array, which, on pushing of a button, will be sent to my controller. My question is, <strong>how can I create a dynamic array in javascript so that a colleague's <code>id</code> is added to the array or removed when unchecked?</strong> </p>

<p>Thanks</p>