Hello folks,
The code and HTML below are from a quiz editor - I have an onClick
function that fires duplicateRow to add another question box onto the
end of the table.
Firefox does what I expect to happen - it selects the last <tr>
row. IE7 and Safari, on the other hand, appear to treat the <tfoot>
as the last tr in the table.
Is there a way to satisfy the interpretation of all three browsers?
Thanks,
Bruce
function duplicateRow(){
var clonedRow = $("#question_table tr:last").clone();
var iRowID = parseFloat(clonedRow.attr("id").replace('t',''));
iNewID = iRowID + 1;
$("#bc"+ iRowID , clonedRow).attr( { "id" : "bc" +
iNewID,"name" : "correctans" + iNewID, "checked":false } );
$("#lba"+ iRowID , clonedRow).attr( { "id" : "lba" +
iNewID,"for" : "theans" + iNewID } );
$("#lbb"+ iRowID , clonedRow).attr( { "id" : "lbb" +
iNewID,"for" : "bc" + iNewID } );
$("#lbc"+ iRowID , clonedRow).attr( { "id" : "lbc" +
iNewID,"for" : "fb" + iNewID } );
$("#sL"+ iRowID , clonedRow).attr( { "id" : "sL" + iNewID} );
$("#fb"+ iRowID , clonedRow).attr( { "id" : "fb" +
iNewID,"name" : "feedback" + iNewID, "value":"" } );
$("#theans"+ iRowID , clonedRow).attr( { "id" : "theans" +
iNewID,"name" : "answer" + iNewID, "value":""} );
$("#question_table").append(clonedRow);
$("#question_table tr:last").attr( "id", "t" + iNewID);
$("#sL"+iNewID).html("Answer "+parseFloat(iNewID+1));
$("#noptions").attr({"value":iNewID});
};
<tr id="t4" class="qdot"><td colspan="2"><p><label class="label7"
id="lba4" for="theans4"><span id="sL4">Answer
5</span></label><textarea rows="3" id="theans4" name="answer4"
class="qinput30">lateral buds only</textarea></p><p><label
class="label7" for="bc4" id="lbb4">Correct?</label><input
name="correctans4" id="bc4" value="1" type="checkbox"></p><p><label
id="lbc4" class="label7"
for="fb4">Feedback<br>(standard)</label><textarea rows="3"
name="feedback4" id="fb4" class="qinput30">while they do occur in
axillary/lateral buds, they also occur at terminal
buds</textarea></p></td></tr></tbody><tfoot><td class="strong
smfont90"><a href="#" onclick="duplicateRow();return false;"
title="Add more options to this question"><img src="images/add.png"
class="timg" alt="Add more options" width="16" height="16"></a> Add
more possible answers</td></tfoot></table>