简体   繁体   English

Laravel 如何使用按钮将数据从表移动到另一个

[英]Laravel how to move data from table to another using button

Is there any simple way to move data from table to another table using the id?有什么简单的方法可以使用 id 将数据从一个表移动到另一个表? I want to get all the info inside the first table using the id, insert it to another table, and then delete it from current one using Laravel.我想使用 id 获取第一个表中的所有信息,将其插入另一个表,然后使用 Laravel 从当前表中删除它。

In my Html table.在我的 Html 表中。 For example I have pending reservation table and there's an action button "accept" then if I will click it the data will go to the accepted reservation table.例如,我有待处理的预订表并且有一个操作按钮“接受”,然后如果我单击它,数据将 go 到已接受的预订表。

Pleaser refer to this photo.请参考这张照片。 enter image description here在此处输入图像描述

you can use sortablejs to do the trick你可以使用sortablejs来解决问题

check this example from the docs文档中检查这个例子

if you are using datatable, then you can do something like that如果你正在使用数据表,那么你可以做类似的事情

 var table1 = $("#pending").DataTable(); var table2 = $("#reserved").DataTable(); $(document).on("click", "#pending.move", function () { var row = table1.row( $(this).parents('tr') ); var rowNode = row.node(); row.remove(); table2.row.add( rowNode ).draw(); }); $(document).on("click", "#reserved.move", function () { var row =table2.row( $(this).parents('tr') ); var rowNode = row.node(); row.remove(); table1.row.add( rowNode ).draw(); });
 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"> <table id="pending" class="table"> <thead> <tr> <th scope="col">#</th> <th scope="col">First</th> <th scope="col">Last</th> <th scope="col">action</th> </tr> </thead> <tbody> <tr> <th scope="row">1</th> <td>Mark</td> <td>Otto</td> <td><button type="button" class="btn btn-primary btn-sm move">move</button></td> </tr> <tr> <th scope="row">2</th> <td>Jacob</td> <td>Thornton</td> <td><button type="button" class="btn btn-primary btn-sm move">move</button></td> </tr> <tr> <th scope="row">3</th> <td>Larry</td> <td>the Bird</td> <td><button type="button" class="btn btn-primary btn-sm move">move</button></td> </tr> </tbody> </table> <table id="reserved" class="table mt-5"> <thead> <tr> <th scope="col">#</th> <th scope="col">First</th> <th scope="col">Last</th> <th scope="col">Action</th> </tr> </thead> <tbody> </tbody> </table> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.21/js/jquery.dataTables.min.js"></script>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel 使用按钮将行数据从表移动到另一个表 - Laravel move row data from table to another table using button 使用javascript或jquery将数据从一个表移动和删除到另一个表 - Move and delete data from one table to another table using javascript or jquery 如何使用AngularJS将人从DropDownList(ddl在表1上)移动到另一个表(表2)? - How can I move a person from a DropDownList (the ddl is on table 1 ) to another table (table 2) using AngularJS? 使用Jquery将表中的特定列数据移动/复制到另一个表中 - Move/Copy Specific columns data of a table in to another table Using Jquery 如何使用javascript将内容从表格的一行移动到另一表格的行 - How to move content from one row of the table to another table row using javascript 如何将表行数据(HTML)从一个php页移动到另一个 - how to move the table row data (HTML) from one php page to another 如何使用Javascript将单元格数据值从HTML表格的一列移到另一列? - How to move cell data values from one column to another in HTML table with Javascript? 如何通过Vue将数据从表组件传递到另一个表组件,并使用编辑按钮传递表中的每一行 - how pass data from a table component in vue to another table component passing each row in the table with an edit button 如何使用angularjs将表数据从一个表移动到另一表 - How can I move table data from one tabe to other table using angularjs 如何在单击按钮时使用AngularJs将文本框的内容移动到另一个文本框? - How to move the content of a textbox into another textbox using AngularJs on button click?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM