hey guys. so i was thinking of creating this page that has 2 different tables : table1(table1 filled with names that are populated from database but lets not think about that part for now) and table2(empty), table1 rows are clickable and when doubleclick on one row the data in that row appends to table2 row but i would like that to also work on table2(moves from table2 to table1). obviously there are other functions that i would like these 2 tables to do but in order to do that i need to figure out the doubleclick functions. I am also wondering how to structure table2 as there is no data how do i fix the rows? i was thinking maybe
<tr><td><input type="textbox" name="guest" style="border:none;outline:none"></td></tr>
but then i know that that is not the right way or acceptable way to do it.

simple tables

<table class="table1">
    <thead><th>Name</th></thead>
    <tbody>
        <tr><td>Nadia</td></tr>
    </tbody>
</table>

<table class="table2">
    <thead><th>Guest</th></thead>
    <tbody>
        <tr><td><input type="textbox" name="guest" id="guest1"></td></tr>
    </tbody>
</table>

the double click code would be something like this(i guess)

<script>
$(".table1 tr").dblclick(function () {
$(".table1 tr.clicked").removeClass("clicked").appendTo('.table2 #guest1');
});
</script>

and so that the rows are clickable i have to add selectable(), right? or wrong?

<script>
    $(function() {
        $( ".table1 tr" ).selectable();
    });
    </script>

pointers/ideas/advice/suggestion are much appreciated.

ps: as i said in table1 in future the names would be populated from database but for learning purposes the name is fixed.

Re: doubleclick table1 row appends to table2 row 80 80

this code works:

$("td").on("dblclick", function(){
    var currTable = $(this).closest("table").attr("id"),
        destinationTable = (currTable.match(/1/))? "#table_2" : "#table_1";
    $(destinationTable).append($(this).parent());
});

though now facing issue that is doesnt work when the table is wrapped in div

Re: doubleclick table1 row appends to table2 row 80 80

fixed. it actually didnt work when i changed the table id because i didnt match it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.