I have form with checkboxes groups, like so:
<input type="checkbox" name="group_one" value="1">
<input type="checkbox" name="group_one" value="2">
<input type="checkbox" name="group_two" value="1">
<input type="checkbox" name="group_two" value="2">
What I'm trying to achieve is on form.change() I would like to have an array with keys of checkboxes names and array of the values, like so
var checkboxes = $('input').filter(':checked');
var myArray = [];
checkboxes.each(function () {
var name = $(this).attr('name');
var val = $(this).val();
myArray[name] = val;
});
As a result I'm trying to get an array with 'name' as keys and 'val' as an array, like so:
[group_one: {1,2}, group_two: {1,2}]
I hope this make sense. Thank you for any help in advance!