else statement not adding content into textarea
<p>I have a function below where the if statement works when it comes to adding content into a single textarea when clicking the "Add" button:</p>

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

    if(window.console) console.log();

    if($(plusbutton_clicked).attr('id')=='mainPlusbutton') { 
        $('#mainTextarea').val(questionText); 
        } else { 
            $(plusbutton_clicked).parent('td').next('td.question').find('textarea.textAreaQuestion').val(questionText);
            }

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

<p>The problem is the else statement is not working when it comes to adding content within one of the appended textareas. What I want is that if a user clicks on a Plus button and adds a content by clicking on the "Add" button, the textarea which belongs in the same row as the plus button which was clicked on will add the content. What do I need to change in order to do this?</p>

<p>Below is the code whch shows the textareas and plus buttons which are appended:</p>

<pre><code>    var plusbutton_clicked;

 function insertQuestion(form) {


var $tbody = $('#qandatbl &gt; tbody'); 
var $tr = $("&lt;tr class='optionAndAnswer' align='center'&gt;&lt;/tr&gt;");
var $plusrow = $("&lt;td class='plusrow'&gt;&lt;/td&gt;");
var $question = $("&lt;td class='question'&gt;&lt;/td&gt;");


 $('.questionTextArea').each( function() {

 var $this = $(this);
var $questionText = $("&lt;textarea class='textAreaQuestion'&gt;&lt;/textarea&gt;").attr('name',$this.attr('name')+"[]")
.attr('value',$this.val());

 $question.append($questionText);

});

 $('.plusimage').each( function() {

var $this = $(this);
var $plusimagerow = $("&lt;a onclick='return plusbutton();'&gt;&lt;img src='Images/plussign.jpg' width='30' height='30' alt='Look Up Previous Question' class='imageplus'/&gt;&lt;/a&gt;").attr('name',$this.attr('name')+"[]")
.attr('value',$this.val());

$plusrow.append($plusimagerow);

 });

$tr.append($plusrow);
$tr.append($question);
$tbody.append($tr);                     

}
</code></pre>

<p>Below is the php code where it displays the "QuestionContent" and "Add" button for each row. When user clicks on the "Add" button it adds the "QuestionContent" into the single textarea on top but not in the multiple textareas which are appended.</p>

<pre><code>  &lt;?php

    $output = "";

            while ($questionrow = mysql_fetch_assoc($questionresult)) {
    $output .= "
    &lt;table&gt;
          &lt;tr&gt;
          &lt;td class='addtd'&gt;&lt;button type='button' class='add' onclick='parent.addwindow();'&gt;Add&lt;/button&gt;&lt;/td&gt;
          &lt;/tr&gt;";
            }
            $output .= "        &lt;/table&gt;";

            echo $output;

            ?&gt; 
</code></pre>

<p>You can view application <a href="http://helios.hud.ac.uk/u0867587/Mobile_app/QandATable2.php" rel="nofollow">here</a>. Please follow the steps to use the application:</p>

<ol>
<li>Click on "Add Question" button, then will add a textarea within a new row.</li>
<li>Click on the "Green Plus" button within the table row you just added, a modal window will appear.</li>
<li>In modal window it displays a search bar, in search bar type in "AAA" and click on "Search" button</li>
<li>Results will appear of your search, click on "Add" button to add a row. You will find out modal window is closed but the content from the "Question" field is not added in the textarea within the row you clicked on the green plus button</li>
</ol>

<p>If you did the steps in the top textarea (the one above the horizontal line), then it does work, it just doesn't work for textarea which you have just added</p>
