title: Javascript give array Key a name while doing an array 'push'
body: <p>I have 3 groups of radio buttons each containing multiple ones. While using the <code>data-toggle="buttons"</code> in bootstrap3 for each group I can make sure, only one answer is selected per group. So far everything is fine.<p>The function below is triggered on a click event and returns the values of the selected items. My problem is how can I handle the returning values stored in the array <code>values</code> and give each key a name corresponding to the group set of buttons. <p> Assuming I select <code>Red + small + Circle</code> then <code>getValues</code> will return the key=> values :</p>
  
  <ul>
  <li>[0] => Red</li>
  <li>[1] => Small</li>
  <li>[2] => Circle</li>
  </ul>
  
  <p>Now, if I select <code>small + Circle</code> :</p>
  
  <ul>
  <li>[0] => Small</li>
  <li>[1]=> Circle</li>
  </ul>
  
  <p>The values are stored as per the order of selection, Im trying to get this values to build a query as per the selection..</p>
  
  <p>Where I want the values to be store in this format :</p>
  
  <ul>
  <li>[color] =>x</li>
  <li>[size] => y</li>
  <li>[shape] => z</li>
  </ul>
  
  <p>d</p>
  
  <pre><code>&lt;input type="radio" name="color" value="red"/&gt; Red     /// Grp 1 Color
  &lt;input type="radio" name="color" value="blue"/&gt; Blue
  &lt;br/&gt;
  &lt;input type="radio" name="size" value="small"/&gt; small   /// Grp2  Size
  &lt;input type="radio" name="size" value ="Large"/&gt; Large
  &lt;br/&gt;
  &lt;input type="radio" name="shape" value="circle"/&gt; Circle  /// Grp3 Shape
  &lt;input type="radio" name="shape" value="square"/&gt; Square
  
  
  function getValues(){
  
  var values = [];
  for(var x = 0; x &lt; radios.length; x++){
      if(radios[x].type == "radio" &amp;&amp; radios[x].checked){
         values.push(radios[x].value);
      }
  }
  return values;
  
  }
  
  $( "#Btn" ).click(function() {
        var x = getValues();
  
  $.each(x, function(k, v) {
  
  //display the key and value pair
        alert(k + ' is ' + v);
  
  });
  </code></pre>
  
  <p>Thanks</p>