How to turn on and off the correct answer buttons?
<p>I have a function below where if the user clicks on the "Add" button, it triggers the function below:</p>

<pre><code>function addwindow(gridValues) { 

    if($(plusbutton_clicked).attr('id')=='mainPlusbutton') { 

        $('#btn'+gridValues).trigger('click');


        } 

    $.modal.close(); 
    return false;
} 
</code></pre>

<p>Now below is the code where it is able to display answer buttons A-Z, "True" or "False" and "Yes" or "No":</p>

<p>Html code:</p>

<pre><code>&lt;?php
    $a = range("A","Z");
?&gt;

&lt;table id="answerSection"&gt;
    &lt;tr&gt;

&lt;?php
    $i = 1;
    foreach($a as $key =&gt; $val){
        if($i%7 == 1) echo"&lt;tr&gt;&lt;td&gt;";
        echo"&lt;input type=\"button\" onclick=\"btnclick(this);\" value=\"$val\" id=\"answer".$val."\" name=\"answer".$val."Name\" class=\"answerBtns answers answerBtnsOff\"&gt;";      
        if($i%7 == 0) echo"&lt;/td&gt;&lt;/tr&gt;";
        $i++;
    }
?&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
&lt;td&gt;
&lt;input class="answerBtns answers" name="answerTrueName"  id="answerTrue"    type="button"   value="True"    onclick="btnclick(this);"/&gt;
&lt;input class="answerBtns answers" name="answerFalseName" id="answerFalse"   type="button"   value="False"   onclick="btnclick(this);"/&gt;
&lt;input class="answerBtns answers" name="answerYesName"   id="answerYes"     type="button"   value="Yes"     onclick="btnclick(this);"/&gt;
&lt;input class="answerBtns answers" name="answerNoName"    id="answerNo"      type="button"   value="No"      onclick="btnclick(this);"/&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>Javascript code:</p>

<pre><code>function getButtons()
{
    var i;
    if (initClick == 0) {
        for (i = 65; i &lt;= 90; i++) { // iterate over character codes for A to Z
            $("#answer" + String.fromCharCode(i)).removeClass("answerBtnsOn").addClass("answerBtnsOff");

        }

        initClick = 1;
    }
    // code above makes sure all buttons start off with class answerBtnsOff, (so all button are white).
}
</code></pre>

<p>Below is the code where it turns on and off the answer buttons:</p>

<pre><code>function btnclick(btn)
{
    var context = $(btn).parents('#optionAndAnswer');

    if ($(btn).hasClass("answerBtnsOn")) {
        $(btn).removeClass("answerBtnsOn").addClass("answerBtnsOff");
        return false;
    }

    if ($(btn).hasClass("answerBtnsOff")) {
        $(btn).removeClass("answerBtnsOff").addClass("answerBtnsOn");
        return false;
    }
}
</code></pre>

<p>Now I have a table column known as "Answers" and each row under that column contains as Answer(s) and its own "Add" button. What my question is that if lets say in one of the rows contains the Answer <code>A B D F</code> and the user adds this row by clicking on the "Add" button, then I want the answer buttons <code>A B D and F</code> to be turned on and the other answer buttons to be turned off. Another example is if the Answer is <code>True</code>, then I want the <code>True</code> answer button to be turned on and the other answer buttons to be turned off.</p>

<p>So what do I need to put in the <code>function addwindow(gridValues)</code> so that when the "Add" button is clicked, its turns on and turn off the correct answer buttons?</p>
