I want my previous code to go into my new code
<p>I have two questions. In my jsfiddle I have a piece of javascript code where the user can type in a question and then click on the "Add Question" to add the question as a new row in the table. Now the code I have in jsfiddle to make this work was fine but I want to change my code so it includes more jquery functions.</p>

<p>Below I have the jquery code I am currently working on where it includes adding an Answer (I have not included the "Answer" feature in the Jsfiddle but I have included the previous code I had for adding an answer to a new Answer in the Jsfiddle):</p>

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

    var $tr = $("&lt;tr&gt;&lt;/tr&gt;");
    var $qid = $("&lt;td class='qid'&gt;" + qnum + "&lt;/td&gt;");
    var $question = $("&lt;td class='question'&gt;&lt;/td&gt;");
    var $answer = $("&lt;td class='answer'&gt;&lt;/td&gt;");

    $('#optionAndAnswer .answerBtnsOn').each( function() {

        var $this = $(this);
        var $newBtn = $("&lt;input class='answerBtns' type='button' style='display: inline-block;' /&gt;").attr('name',$this.attr('name'))
                   .attr('value',$this.attr('value'))
                   .attr('id','qid' + qnum + '-' + $this.attr('id')); // must be unique
        $answer.append($newBtn);
    });

    $tr.append($qid);
    $tr.append($answer);
    $('#qandatbl').append($tr);

    form.numberOfQuestions.value = qnum;

    ++qnum;
    $("#questionNum").text(qnum);
    form.questionText.value = "";

}
</code></pre>

<p>What I want to know is how can I include the piece of code which adds the question into a new row into the piece of code above. Below is the adding the question code in the jsfiddle:</p>

<pre><code>cell = document.createElement("td"),
input = document.createElement("textarea");
cell.className = "question";
input.name = "question_" + qnum;
input.value = form.questionText.value;
cell.appendChild(input);
row.appendChild(cell);
</code></pre>

<p>Also in my current code how can I get it so that the question No (qnum) always + 1 eveytime a new row is added. At the moment the question number equals 1 for each row added when it should go question no 1 for first row, question no 2 for second row etc</p>

<p>thanks</p>
