I am trying to wrtie the code in jquery which is call when the user clicks on the Add button. the function should take the value of the index of the row and add new row with some input elements in it at the end of the table. Here is something I tried, but I am going nowhere.
/* This is the jquery */
$("#add").click(function() {
var fieldWrapper = NULL;
var no_checkbox = $('<input type="checkbox" class="css-checkbox" id="checkbox[$index]"/><label for="checkbox[$index]" name="checkbox_lbl" class="css-label lite-x-red"></label>');
no_checkbox.wrap('<td></td>');
var q = $('<textarea name="question[]" id="bigarea" style="text-align:left;">');
q.wrap('<td></td>');
var yes_checkbox = $('<input name="qchecked[]" type="checkbox" class="css-checkbox" id="checkbox[$index]"/><label for="checkbox[$index]" class="css-label lite-y-green"></label>');
yes_checkbox.wrap('<td></td>');
var percentdropdown = '<select style="width:50px; height:25px;" />';
for (var j = 0; j < 101; j += 5) {
percentdropdown.append('<option name="effectiveness" value="j">j</option>');
}
var comment_box = '<textarea id="smallarea" placeholder="comments" name="comments[]"></textarea>';
comment_box.wrap('<td></td>');
fieldWrapper.append(no_checkbox);
fieldWrapper.append(q);
fieldWrapper.append(yes_checkbox);
fieldWrapper.append(percentdropdown);
fieldWrapper.append(comment_box);
fieldWrapper.wrap('<tr></tr>');
$("#checklist").append(fieldWrapper);
});
/* Here is the code on the button */
echo "<div class=savebtn align=center >";
echo "<input style='margin-bottom: 5px;margin-right:20px;' type='button' value='Add New Question' id='add'>";
echo "<input style='margin-bottom: 5px;' type='submit' value='Save' name='chklst_save'>";
echo "</div>";
This is how I want the row to be added. Please help.

append,wrap..) on strings not on objects.