command keeps repeating n Number of times

command keeps repeating n Number of times

Hi,

I am new to this forum and Jquery. I need help with this code

I have two tables table1 on the left  and SelStudent on the right.
table1 has checkbox on each row which when clicked fires the function below.

My problem is
when I click a checkbox on any row in table1,      1  record is appended to SelStudent Table
  $("#SelStudent").append(ttext);   runs once, as expected)
when I click another checkbox in any row of table1, 2 records are appended to SelStudent table
  $("#SelStudent").append(ttext);  runs twice (why?)
when I click another checkbox in any row of table1, 3 records are append to SelStudent
  $("#SelStudent").append(ttext); runs three times (why?)

What is wrong with my code? Can someone please point out my mistake and suggest a solution?


    function moveOneRow(r_id) {
        alert(r_id); ............................................................. (runs just once)
        $('#table1').on('click', 'tr', function (event) {
            var ttext = "";
            var currentRow = $(this).closest("tr");
            var name = currentRow.find("td:eq(0)").text();
            var rowid = currentRow.find("td:eq(2)").text();
            var father = currentRow.find("td:eq(3)").text();
            var otele = currentRow.find("td:eq(5)").text();

            ttext =
             '<tr id=' + rowid + '>' +
             '<td>' + father + '</td>' +
             '<td>' + name + '</td>' +
             '<td>' + otele + '</td>' +
             '<td><input type="checkbox" class="form-check-input" onclick="removeRow(' + rowid + ')"></td>' +
                '</tr>'

            alert(ttext);

            $("#SelStudent").append(ttext);
            ttext = ""
            alert(ttext);
        });
    }