title: jquery arrays intersect
body: <p>I previously posted this question as jquery/javascript: arrays - <a href="https://stackoverflow.com/questions/3969576/jquery-javascript-arrays">jquery/javascript: arrays</a>.
  But since I am a complete beginner I have formulated the question wrong and didn't understand the answers either.... :(</p>
  
  <p>After failing to implement the given solutions I did some more looking around I found out that I need to compare 6 arrays of possible choices and intersect them to finally display only the overlapping values.</p>
  
  <p>So this is, hopely, a clearer formulation:</p>
  
  <p>I have 6 questions/6 groups of radio buttons for answers. Each answer has multiple values (they can range from 1 to 38 items to be displayed in final 'advice'). I am collecting the values of checked radios in arrays. I get 6 arrays. </p>
  
  <p>How do I intersect 6 arrays in order to get one final array containing only intersecting values form all 6 choices?
  How do I turn items of this final array into selectors?</p>
  
  <p>Can someone please help me?
  Thank you!</p>
  
  <p>My script looks now like:</p>
  
  <pre><code>(function($){
    $.fn.checkboxval = function(){
        var outArr = [];
        this.filter(':checked').each(function(){
              outArr.push(this.getAttribute("value"));
        });
        return outArr;
    };
  })
  (jQuery);
  $(function(){
    $('#link').click(function(){
      var valArr1 = $('#vraag1 input:radio:checked').checkboxval();
      var valArr2 = $('#vraag2 input:radio:checked').checkboxval();
      var valArr3 = $('#vraag3 input:radio:checked').checkboxval();
      var valArr4 = $('#vraag4 input:radio:checked').checkboxval();
      var valArr5 = $('#vraag5 input:radio:checked').checkboxval();
      var valArr6 = $('#vraag6 input:radio:checked').checkboxval();
  // var newArray = $.merge(valArr1, valArr2, valArr3, valArr4, valArr5, valArr6); &lt;- test to see if I can merge them
  // $('#output').text(newArray.join(',')); &lt;- test to see if I can join them
  //$("#output").html($("#output").html().replace(/,/gi, ',#diet')); &lt;- test to see if I can append text so it looks like the selectors of divs I need to display later
  //    return false;
    });
  });
  </code></pre>
  
  <p>my form/inputs looks like:</p>
  
  <pre><code>&lt;input name="vraag1" type="radio" value="1a,4,5,12,13,17a,18,19,22,23,24,26,27,28,29,30,33,38,6" class="radio advice" id="vraag1-0" /&gt;&lt;label for="vraag1-0"&gt;ja&lt;/label&gt;
  &lt;br /&gt;
  &lt;input name="vraag1" type="radio" value="1b,1,2,3,7,8,11,9,14,15,16,17,20,21,25,31,34,35,36,37,10,32" class="radio advice" id="vraag1-1" /&gt;&lt;label for="vraag1-1"&gt;nee&lt;/label&gt;
  &lt;br /&gt;
  &lt;input name="vraag1" type="radio" value="1c,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,17a,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38" class="radio advice" id="vraag1-2" /&gt;&lt;label for="vraag1-2"&gt;maakt mij niet uit&lt;/label&gt;
  </code></pre>