Erwin Erwin - 5 months ago 24
jQuery Question

jQuery how to take all multiple form data in one array?

I want to have all data of my forms in one array

$('#teamMedewerker :selected').each(function(i){
var form = $("form#urenformulier" + i).serializeArray();
$.each($(form), function(i, field){
//console.log( + " : " + field.value);
array = field.value;

I want this result but dont know how to get this.

Array (employee1(test,test,test), employee2(test1,test2,test3))

each form is an employee, there are multiple forms.


If i understand correctly you should use map instead of each

var arrayOfEmployees = $('#teamMedewerker :selected').map(function(i){
    return [$("form#urenformulier" + i).serializeArray()];

Now if you want to iterate over this you can do

         console.log(, field.value);