I'm in the process of creating a website that features an input table allowing users to easily add or remove rows at their discretion. The desired UI is shown below:
https://i.sstatic.net/EFAlM.jpg
Here is the HTML code I have developed so far:
<div class="container my-5">
<h2>Welcome to dynamic input table with row adding option</h2>
<form method="" action="">
<table class="table table-hover my-5">
<thead class="">
<tr>
<th>No</th>
<th>Name</th>
<th>Pnone Number</th>
<th>Email</th>
<th>Remove?</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td><input type="text" name="name-1"></td>
<td><input type="text" name="phone-1"></td>
<td><input type="text" name="Email-1"></td>
<td><i class="fa fa-times-circle" style="font-size: 22px; color: red;"></i></td>
</tr>
<tr>
<td>2</td>
<td><input type="text" name="name-2"></td>
<td><input type="text" name="phone-2"></td>
<td><input type="text" name="Email-2"></td>
<td><i class="fa fa-times-circle" style="font-size: 22px; color: red;"></i></td>
</tr>
<tr>
<td>3</td>
<td><input type="text" name="name-3"></td>
<td><input type="text" name="phone-3"></td>
<td><input type="text" name="Email-3"></td>
<td><i class="fa fa-times-circle" style="font-size: 22px; color: red;"></i></td>
</tr>
<tr>
<td>4</td>
<td><input type="text" name="name-4"></td>
<td><input type="text" name="phone-4"></td>
<td><input type="text" name="Email-4"></td>
<td><i class="fa fa-times-circle" style="font-size: 22px; color: red;"></i></td>
</tr>
</tbody>
</table>
<div class="row m-0">
<button class="btn btn-warning">Add row</button>
<button class="btn btn-danger ml-3">Delete last row</button>
<button type="Submit" class="btn btn-primary ml-auto">Submit</button>
</div>
</form>
</div>
<head>
<title></title>
<!-- media query support -->
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<!-- font awsome css link -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
I am currently seeking guidance on how to effectively implement functionalities for the 'Add row', 'Delete last row' buttons, and the ability to remove rows. These functions should also seamlessly integrate with back-end data processing using Django and MongoDB. Any suggestions on implementing these using frontend JavaScript or handling them dynamically on the backend would be greatly appreciated.