title: JavaScript create multi level object
body: <p>I want to create an object like this:</p>
  
  <pre><code>var exampleObject = {
      '1' : ['2','3','7'],
      '2' : ['4','7'],
      '4' : ['5','1','2']
    };
  </code></pre>
  
  <p>from a list of inputs fields:</p>
  
  <pre><code>&lt;input type="checkbox" class="flat-red" name="1" value="2"&gt;
  &lt;input type="checkbox" class="flat-red" name="1" value="3"&gt;
  &lt;input type="checkbox" class="flat-red" name="1" value="7"&gt;
  &lt;input type="checkbox" class="flat-red" name="2" value="4"&gt;
  &lt;input type="checkbox" class="flat-red" name="2" value="7"&gt;
  &lt;input type="checkbox" class="flat-red" name="4" value="5"&gt;
  &lt;input type="checkbox" class="flat-red" name="4" value="1"&gt;
  &lt;input type="checkbox" class="flat-red" name="4" value="2"&gt;
  </code></pre>
  
  <p>The idea is that for each input with the same "name" attribute i would like to have the values from the "value" field in the input. I have tried different approaches but without success. Any suggestion on how i could achieve this?</p>