Server IP : 162.240.98.243 / Your IP : 18.191.93.12 Web Server : Apache System : Linux server.bti.yaw.mybluehostin.me 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : btiyawmy ( 1003) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/btiyawmy/public_html/login.easenup.in/ |
Upload File : |
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery Add / Remove Table Rows Dynamically</title> <style> form{ margin: 20px 0; } form input, button{ padding: 5px; } table{ width: 100%; margin-bottom: 20px; border-collapse: collapse; } table, th, td{ border: 1px solid #cdcdcd; } table th, table td{ padding: 10px; text-align: left; } </style> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script> $(document).ready(function(){ $(".add-row").click(function(){ var name = $("#name").val(); var email = $("#email").val(); var markup = "<tr><td><input type='checkbox' name='record'></td><td>" + name + "</td><td>" + email + "</td></tr>"; $("table tbody").append(markup); }); // Find and remove selected table rows $(".delete-row").click(function(){ $("table tbody").find('input[name="record"]').each(function(){ if($(this).is(":checked")){ $(this).parents("tr").remove(); } }); }); }); </script> </head> <body> <form action="action24marth.php" method="POST"> <input type="text" id="name" name='name[]' placeholder="Name"> <input type="text" id="email" name='email[]' placeholder="Email Address"> <input type="submit" class="add-row" value="Add Row"> </form> <table> <thead> <tr> <th>Select</th> <th>Name</th> <th>Email</th> </tr> </thead> <tbody> <tr> <td><input type="checkbox" name="record"></td> <td><input type='text' id='name' name='name[]' value='Peter Parker'></td> <td><input type='text' id='email' name='email[]' value='peterparker@mail.com'></td> </tr> <tr> <td><input type="checkbox" name="record"></td> <td><input type='text' id='name' name='name[]' value='Peter Parker'></td> <td><input type='text' id='email' name='email[]' value='peterparker@mail.com'></td> </tr> <tr> <td><input type="checkbox" name="record"></td> <td><input type='text' id='name' name='name[]' value='Peter Parker'></td> <td><input type='text' id='email' name='email[]' value='peterparker@mail.com'></td> </tr> <tr> <td><input type="checkbox" name="record"></td> <td><input type='text' id='name' name='name[]' value='Peter Parker'></td> <td><input type='text' id='email' name='email[]' value='peterparker@mail.com'></td> </tr> <?php session_start(); include('dbconnection.php'); $sql1 ="SELECT * FROM trytest ORDER BY id ASC"; $qsql1 = mysqli_query($con,$sql1); while($rspi1 = mysqli_fetch_array($qsql1)) { echo" <tr> <td>$rspi1[id]</td> <td>$rspi1[name]</td> <td>$rspi1[email]</td> </tr> "; } ?> </tbody> </table> <button type="button" class="delete-row">Delete Row</button> </body> </html>