How to post values of buttons which are turned on?
<p>I need help on being able to post the correct buttons into the database. But I don't know what to call the $_POST method when posting the values of the button.</p>

<p>I have an application which you can view <a href="http://helios.hud.ac.uk/u0867587/Mobile_app/QandATable2.php" rel="nofollow">here</a></p>

<p>Please follow steps below in order to use application:</p>

<ol>
<li>Click on the "Open Grid" link and select button "5", you will see 5 buttons "A-E" appear below.</li>
<li>Click on button 'A' and 'C', these buttons would turn green meaning that they have been turned on.</li>
<li>Now click on the "Add question" button to append what you have done into a table row below.</li>
<li>Now please repeat steps 1-3 again but this time choose button "7" so you will see buttons "A-G" and click on buttons 'B', 'D' and 'F' so that these buttons are turned on.</li>
</ol>

<p>Now you will see that there are 2 table rows, first table row has buttons 'A' and 'C' turned on and second row has buttons 'B', 'D' and 'F' turned on.</p>

<p>What my question is that how do I $_POST only those turned on buttons only (In example above it should post 'A' and 'C', and it should post 'B', 'D' and 'F'? What is the $_POST method I need to write?</p>

<p>Below is the code where it outputs the letter buttons in the top control and in the appended rows:</p>

<p>Letter buttons in top control</p>

<pre><code>&lt;table id="optionAndAnswer" class="optionAndAnswer"&gt;
&lt;tr&gt;
      &lt;th colspan="2"&gt;
        Option and Answer
    &lt;/th&gt;
&lt;/tr&gt;
        &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 answerBtnsOff" name="answerTrueName"  id="answerTrue"  type="button"   value="True"    onclick="btnclick(this);"/&gt;
        &lt;input class="answerBtns answers answerBtnsOff" name="answerFalseName" id="answerFalse"     type="button"   value="False"   onclick="btnclick(this);"/&gt;
        &lt;input class="answerBtns answers answerBtnsOff" name="answerYesName"   id="answerYes"   type="button"   value="Yes"     onclick="btnclick(this);"/&gt;
        &lt;input class="answerBtns answers answerBtnsOff" name="answerNoName"    id="answerNo"        type="button"   value="No"      onclick="btnclick(this);"/&gt;
        &lt;/td&gt;
        &lt;/tr&gt;
        &lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>Below is letter buttons appended into each row</p>

<pre><code>    function insertQuestion(form) {   

                var context = $('#optionAndAnswer');
        var currenttotal = context.find('.answerBtnsOn').length;        



        var $tbody = $('#qandatbl &gt; tbody'); 
        var $tr = $("&lt;tr class='optionAndAnswer' align='center'&gt;");
        var $td = $("&lt;td class='extratd'&gt;");
        var $answer = $("&lt;div class='answer'&gt;3. Answer:&lt;br/&gt;&lt;/div&gt;");


    var $this, i=0, $row, $cell;
    $('#optionAndAnswer .answers').each(function() {
        $this = $(this);
        if(i%7 == 0) {
            $row = $("&lt;tr/&gt;").appendTo($answer);
            $cell = $("&lt;td/&gt;").appendTo($row);
        }
        var $newBtn = $("&lt;input class='answerBtnsRow answers' type='button' style='display:%s;' onclick='btnclick(this);' /&gt;".replace('%s',$this.is(':visible')?'inline-block':'none')).attr('name', $this.attr('name')).attr('value', $this.val()).attr('class', $this.attr('class')).attr('id', $this.attr('id')+'Row');

        $newBtn.appendTo($cell);

        i++;
    });


        $tr.append($td);
        $td.append($answer);
        $tbody.append($tr); 


    }
</code></pre>

<p>Below is the jquery function where it turns on and off the buttons:</p>

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

$(btn).toggleClass("answerBtnsOff");
$(btn).toggleClass("answerBtnsOn");

    return false;
}
</code></pre>
