title: get multidimensional input with jQuery
body: <p>I have a checkbox with multidimensional array which I was using with php submiting. Now I'm rebuilding my code to use ajax.</p>
  
  <pre><code>&lt;li class="formVariationParent"&gt;
    &lt;input checked="" name="variationParent[]" autocomplete="off" value="3" type="checkbox"&gt;colors
      &lt;ul&gt;
        &lt;li class="formVariationChild"&gt;
          &lt;input checked="" name="variationChild[edit_var_val][3][4]" autocomplete="off" value="1" type="checkbox"&gt;red&lt;/li&gt;
     &lt;/ul&gt;
     &lt;ul&gt;
       &lt;li class="formVariationChild"&gt;
         &lt;input checked="" name="variationChild[edit_var_val][3][5]" autocomplete="off" value="1" type="checkbox"&gt;green
       &lt;/li&gt;
     &lt;/ul&gt;
     &lt;ul&gt;
       &lt;li class="formVariationChild"&gt;
         &lt;input checked="" name="variationChild[edit_var_val][3][6]" autocomplete="off" value="1" type="checkbox"&gt;blue
       &lt;/li&gt;
     &lt;/ul&gt;
  </code></pre>
  
  <p></li></p>
  
  <p>And this is how it's generated:</p>
  
  <pre><code>&lt;fieldset&gt;
  
      &lt;a class="btn btn-new btn-primary" onclick="apfGenerateVariation(&lt;?php echo $current_post ?&gt;,&lt;?php echo $get_admin_blog ?&gt;,data);" style="cursor: pointer"&gt;
          &lt;b&gt;&lt;i class="icofont-star"&gt;&lt;/i&gt;&lt;/b&gt;
      &lt;/a&gt;
      &lt;ul class="formVariations" id="formVariationsID"&gt;&lt;li&gt;
          &lt;?php
              $parentArray = array();
              foreach ($parentVariations as $variation) {
                  $parentArray[] = $variation-&gt;term_id;
              }
              foreach($variationCategories as $category) {
                  //var_dump($category);
                  //echo ;
                  // check if this variation is already checked
                  if (in_array($category-&gt;term_id, $parentArray)) {
                      if ($category-&gt;parent == 0) {
                          echo "&lt;/li&gt;&lt;li class='formVariationParent'&gt;&lt;input type='checkbox' checked name='variationParent[]' autocomplete='off' value='". $category-&gt;term_id ."'&gt;" . $category-&gt;name . "";
                      } else {
                          echo "&lt;ul&gt;&lt;li class='formVariationChild'&gt;&lt;input type='checkbox' checked name='variationChild[edit_var_val][". $category-&gt;parent ."][". $category-&gt;term_id ."]' autocomplete='off' value='1'&gt;" . $category-&gt;name . "&lt;/li&gt;&lt;/ul&gt;";
                      }
                  } else {
                      if ($category-&gt;parent == 0) {
                          echo "&lt;/li&gt;&lt;li class='formVariationParent'&gt;&lt;input type='checkbox' name='variationParent[]' autocomplete='off' value='". $category-&gt;term_id ."'&gt;" . $category-&gt;name . "";
                      } else {
                          echo "&lt;ul&gt;&lt;li class='formVariationChild'&gt;&lt;input type='checkbox' name='variationChild[edit_var_val][". $category-&gt;parent ."][". $category-&gt;term_id ."]' autocomplete='off' value='1'&gt;" . $category-&gt;name . "&lt;/li&gt;&lt;/ul&gt;";
                      }
                  }
              }
          ?&gt;
      &lt;/ul&gt;
  &lt;/fieldset&gt;
  </code></pre>
  
  <p>Now I want to select this <code>variationChild</code> with jQuery and save in variable <code>data</code> as if it was submited.</p>
  
  <p>In input name second parenteses are <code>parentID</code> and third <code>childID</code>. I have thouse variables in php so I can rebuild this input however I want but in the and checked <code>data</code> should look like this:</p>
  
  <pre><code>array(1) {
      ["edit_var_val"]=&gt; array(2) {
          [3]=&gt; array(3) {
              [6]=&gt; string(1) "1"
              [5]=&gt; string(1) "1"
              [4]=&gt; string(1) "1"
          }
          [12]=&gt; array(3) {
              [13]=&gt; string(1) "1"
              [14]=&gt; string(1) "1"
              [15]=&gt; string(1) "1"
          }
      }
  }
  </code></pre>
  
  <p>Here first array is this inputs with <code>parentID 3</code> and second, the continue of this form, other <code>ParentID</code>.</p>
  
  <p>This is a jQuery I try to use.</p>
  
  <pre><code>var data = { 'edit_var_val[]' : []};
  jQuery(".formVariationChild input:checked").each(function() {       
      data['edit_var_val[]'].push(jQuery(this).attr('name'));
  });
  </code></pre>
  
  <p>I'm using jQuery <code>.map()</code> and <code>.get()</code> functions, but I guess this is different case.</p>
  
  <p>So how to get checked input and save in variable as this array?</p>