1

私はテーブルを持っています。選択変数の変更時に、行が生成されます。私がやりたいことは、最初の行に書き込んだデータを、生成された行にコピーする必要があるということです。これは私のテーブルと Java スクリプトです。

<form>
    <table border = "1" id = "engagements">
        <tr>
            <th><input type="checkbox" onclick="checkAll(this)"></th>
            <th>Organization</th>
            <th>Project</th>
            <th>Product</th>
            <th>Activity</th>
        </tr>
        <tr>
            <td><input type="checkbox" onclick="checkAll(this)"></td>
            <td><input type = "text"/></td>
            <td><input type = "text"/></td>
            <td><input type = "text"/></td>
            <td><input type = "text"/></td>
            <!--
            <td><input type = "text"/></td>
            <td><input type = "text"/></td>
            <td><input type = "text"/></td>
            <td><input type = "text"/></td>
            <td><input type = "text"/></td>
            -->
        </tr>
    </table>

    <select name = "mode" id = "mode" onchange="addrow('engagements')">
        <option value="">Add More Rows with Same Data as Above</option>
        <option value="1">1 More</option>
        <option value="2">2 More</option>
        <option value="3">3 More</option>
        <option value="4">4 More</option>
        <option value="5">5 More</option>
     </select>

</form>


<script language="javascript">
    function addrow(tableID)
    {
        var table = document.getElementById(tableID);
        var rowCount = table.rows.length;
        var row = table.insertRow(rowCount);
        var colCount = table.rows[0].cells.length;
        var e = document.getElementById("mode");
        var strUser = e.options[e.selectedIndex].value;

        for (var j = 0; j < strUser; j++)
        {
            for (var i = 0; i < colCount; i++)
            {
                var newcell = row.insertCell(i);
                newcell.innerHTML = table.rows[1].cells[i].innerHTML;
            }
            var row = table.insertRow(rowCount);
        }
    }
</script>
4

4 に答える 4

1
$('#step_table').append($('#step_table tr:last td:last').html());
于 2013-07-06T18:54:21.877 に答える