Add previous row data to dynamically generated row

0 votes
80 views
asked Jun 21, 2013 in HTML by john (4,220 points)

    I have a table. onchange of select variable, it generates rows. what i want to do is that, the data which i wrote in the first row, should be copied in the generated rows.

1 Answer

0 votes
answered Jun 21, 2013 by admin (8,115 points)

$("#mode").on('change', function () {
    var rows = parseInt(this.value);
    var lastRow;
    for (var i = 0; i < rows; i++) {
        lastRow = $('#engagements tr').last().clone();
        $('#engagements tr').last().after(lastRow);
    }
});
Demo ----> http://jsfiddle.net/jW6eL/

...