How to select all checkboxes that are denoted by a two dimensional array?
<p><br>
I have a question div which looks like so:  </p>

<pre><code>&lt;div  class="Q"&gt;
&lt;div id="Q1"&gt;&lt;span&gt;1. &lt;/span&gt;Which of the following have the same meaning?&lt;/div&gt;
&lt;div class="A"&gt;&lt;input type="checkbox"  id="Q1A1Correct" /&gt;&lt;input type="checkbox" id="Q1A1User" class="UserA"/&gt;&lt;span id="Q1A1Text"&gt;String&lt;/span&gt;&lt;/div&gt; 
&lt;div class="A"&gt;&lt;input type="checkbox"  id="Q1A2Correct" /&gt;&lt;input type="checkbox" id="Q1A2User" class="UserA"/&gt;&lt;span id="Q1A2Text"&gt;string&lt;/span&gt;&lt;/div&gt;
&lt;div class="A"&gt;&lt;input type="checkbox" id="Q1A3Correct" /&gt;&lt;input type="checkbox" id="Q1A3User" class="UserA"/&gt;&lt;span id="Q1A3Text"&gt;Integer&lt;/span&gt;&lt;/div&gt;
&lt;div class="A"&gt;&lt;input type="checkbox"  id="Q1A4Correct" /&gt;&lt;input type="checkbox" id="Q1A4User" class="UserA"/&gt;&lt;span id="Q1A4Text"&gt;int&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>And I also have a two dimensional array which denotes the type of each question and it's correct answers, e.g.  </p>

<pre><code>var correctAnswers=[["multipleAnswer","1","2"],["multipleAnswer","2","3"]];  
</code></pre>

<p>Denotes that questions 1 and 2 (first two element in the array) are multiple answer questions (let's assume that's the only kind), and their correct answers are 1 and 2 for question 1, and 2 and 3 for question 2.<br>
Now I need to check each checkbox which is a correct answer (i.e. for question 1 - <code>Q1A1Correct</code> and <code>Q1A2Correct</code>).<br>
I managed doing that for a specific question:  </p>

<pre><code>    var correctAs={};
    correctAs.Q1 = ["checkbox","1","2"];

    $('#checkAs').click(function(){
        $.each(correctAs.Q1,function()
        { 
            $("#Q1A"+this+"Correct").attr('checked', true);
        }); //mark correct As according to array above            

});
</code></pre>

<p>But I can't generalize my code so that it will work with the two dimensional array.  </p>

<p>So my question is - how do I check all correct answers for all questions given the array? (changing the way the array is built is an option if that'll be helpful)  </p>

<p>Thanks for your time</p>
