I want to create an object like this:
var exampleObject = {
'1' : ['2','3','7'],
'2' : ['4','7'],
'4' : ['5','1','2']
};
from a list of inputs fields:
<input type="checkbox" class="flat-red" name="1" value="2">
<input type="checkbox" class="flat-red" name="1" value="3">
<input type="checkbox" class="flat-red" name="1" value="7">
<input type="checkbox" class="flat-red" name="2" value="4">
<input type="checkbox" class="flat-red" name="2" value="7">
<input type="checkbox" class="flat-red" name="4" value="5">
<input type="checkbox" class="flat-red" name="4" value="1">
<input type="checkbox" class="flat-red" name="4" value="2">
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?