title: Serialize form - input's with same name
body: <p>I have the followin code : </p>
  
  <pre><code>&lt;form id="sendObj"&gt;
          &lt;table class="no-border hover list"&gt;
            &lt;tbody class="no-border-y"&gt;';
              while($pendingTransfers = mysql_fetch_assoc($getPending)){
                  $id = $pendingTransfers['id'];
                  echo '
              &lt;tr class="items"&gt;
                &lt;td style="width: 10%;"&gt;&lt;span class="label label-primary"&gt;'.$counter++.'&lt;/span&gt;&lt;/td&gt;
                &lt;td class="text-left"&gt;&lt;p&gt;'.$pendingTransfers['NumarInventar'].'&lt;/p&gt;&lt;/td&gt;
                &lt;td class="text-left"&gt;&lt;p&gt;&lt;strong&gt;'.$pendingTransfers['DenumireArticol'].'&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
                  &lt;input type="hidden" name="id" value="'.$pendingTransfers['id'].'" /&gt;
                  &lt;td class="text-center"&gt;&lt;input type="hidden" name="depID" class="getDep" data-placeholder="Selecteaza destinatie" /&gt;  &lt;i style="color:red" title="Sterge din lista" onclick="deleteLista('.$pendingTransfers['id'].');" class="text-right fa fa-times-circle fa-lg"&gt;&lt;/i&gt;&lt;/td&gt;
              &lt;/tr&gt;';}
                  echo '
             &lt;/tbody&gt;
          &lt;/table&gt;
              &lt;/form&gt;     
  &lt;div class="text-center"&gt;&lt;button id="BtnSendObj" type="submit" class="btn btn-primary btn-success"&gt;&lt;i class="fa fa-check color-inverse fa-lg"&gt;&lt;/i&gt; Finish transfers&lt;/button&gt;&lt;/div&gt;
  </code></pre>
  
  <p>The above code brings the inserted DB id for each record and on each row in the above table an select option from wich the user can chose some value. When user finishes , he will press the button " Finish transfers" and all the inputs must be serialized. The problem is that i have multiple inputs with same name and i cannot group them all as i can use them later in PHP. For exemple i can have 5 row's on each row 1 of each input . So the result will <strong>id=1 DepId=3456 , id =2 DepId = 5432</strong> and so on.</p>
  
  <pre><code>$('#BtnSendObj').on('click', function(event) {
      event.preventDefault();
      var data;
      var a = $('#sendObj').serializeArray();
  
      $.each(a, function () {
      var depID = $('input[name=depDestinatie]').serializeArray();
      var id = $('input[name=id]').serializeArray();
  
       data =[{"id":id, "depID":depID}];  
      }); 
  
      //The above will output something like :
      // [Object]0: Object
      //depId: Array[4]0: Object1: Object2: Object3: Object...
      // id: Array[4]0: Object1: Object2: Object3: Object
  
      // Like this i cannot handle them togerther in PHP.
      // I think it should look like an array of objects so like this i would   //be able to acces them easly , i think that both id's should be in same object //, but this is were i dont know how to proceed.
      $.ajax({
          url: 'subpages/data/transferObjects.php',
          data: {data: data},
          type: 'POST',
          success:function(data, textStatus, jqXHR){
              console.log('AJAX SUCCESS');
              console.log(data);
          }, 
          complete : function(data, textStatus, jqXHR){
  
          }
  });
  });
  </code></pre>
  
  <p>Here i handle the ajax post.</p>
  
  <p>What i want to achieve it's to send the data to a php file where i will update DB with the values from the form.</p>
  
  <p>The php files looks like this :</p>
  
  <pre><code>//some connection 
          if(isset($_POST['data']))
      {
      $updateObjects = mysql_query("UPDATE transactions SET IDDepartamentDestinatie = '$_POST['depID'] WHERE id = '{$_POST['id']}'");
  
      }
  </code></pre>
  
  <p>But like this it will only update the last record from the form as i dont loop through all inputs.</p>
  
  <p>If someone has some idee how can i do this , i've tried all examples found about serializeArray or serialize, but didnt worked for me.</p>