asked on March 13, 2019 Show version history

Hi,

I'm currently trying to copy over all values from a chosen row to another table. 

I can easily get the Javascript working on a conventional table built in html so I'm not sure exactly how the DOM In Forms is different. The below structure works fine for the code I will post below. The only thing I can think is if the TR are already present in table 2. I was able to get this to work fine with the clone function in jQuery but unfortunately we can't save a form as draft if we use this as it does not retain data in the dom.

<tbody>
        <tr>
            <td><input checked='checked' type='checkbox' /></td>
            <td>1</td>
            <td>1a</td>
            <td>1b</td>
        </tr>
</tbody>
</table>
<table id='table2'>
    <tbody>
    </tbody>
$(document).ready(function()  {
    $('#add').on("click", function()  {
        $('#table2 tbody').empty();
        var $newrow,
            $newcolumn;
        $('#table1 tbody input:checked').parent().parent().each(function() {
            $newrow = $('<tr></tr>').appendTo($('#table2 tbody'));
            $("td", this).each(function() {
                if($("input", this).length == 0) {
                    $newcolumn = $("<td><input type='text' /></td>").appendTo($newrow);
                    $("input", $newcolumn).val($(this).text());
                }
            });
        });
    });
});

Working fiddle here: https://jsfiddle.net/v5agtrpv/   There must be something different in the format of Laserfiche forms tables to this html table.  I have a feeling that :  $('#table1 tbody input:checked').parent().parent().each(function() isn't quite right 

0 0