Below is my javascript and form code where it appends a question number (qnum) for each table row appended in the application one by one. So if user adds a table row then it contains question number 1, when second row is added, question number 2 is added, then 3 for third row and etc.
<script>
function insertQuestion(form) {
var $tbody = $('#qandatbl > tbody');
var $tr = $("<tr class='optionAndAnswer' align='center'></tr>");
var $qid = $("<td class='qid'>" + qnum + "</td>");
$tr.append($qid);
$tbody.append($tr);
++qnum;
$("#questionNum").text(qnum);
</script>
<form id="QandA" action="insertQuestion.php" method="post" >
<div id="detailsBlock">
<table id="question">
<tr>
<th colspan="2">
Question Number <span id="questionNum">1</span>
</th>
</tr>
</table>
</form>
The problem I have is that I want to do a $_POST in the next page for all the question numbers added. The only problem is that because I am not using an input field, I do not have a name attribute to $_POST. so what I want to know is that if I can use ‘name’ attribute to $_POST, then how else can I post the question numbers?
You can do something like this. Add a hidden field to your markup. Hidden variables are posted back to the server and are available in $_POST with their name. I have added the 2 lines starting with ** and ending with **