Building a Dynamic Data Entry Form with JavaScript and Bootstrap

Building a Dynamic Data Entry Form with JavaScript and Bootstrap

Learn how to create a dynamic data entry form with JavaScript and Bootstrap in this tutorial. This tutorial will guide you through the process of building a user-friendly interface where users can input data and dynamically add or remove entries. Utilizing HTML, CSS (Bootstrap), and JavaScript, you'll understand how to dynamically generate HTML elements, handle user interactions, and manipulate the DOM to achieve a seamless user experience. Whether you're a beginner looking to enhance your skills or an experienced developer seeking to streamline data entry processes, this tutorial has got you covered. Start building your dynamic data entry form today and take your web development skills to the next level!

Code : 

<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
   <title>Create dynamic html Tag</title>
</head>
<body>
   <table class="table" id="tab">
       <tr>
           <th>Name</th>
           <th>Father Name</th>
           <th>Mobile</th>
           <th><a href="#" id="add_btn"  class="btn btn-primary">Add</a></th>
       </tr>

   
   </table>

   <script>
document.getElementById("add_btn").addEventListener('click',function(){

   var html = `<tr>
           <td><input class="form-control" placeholder="Enter Your name" type="text"></td>
           <td><input class="form-control"  placeholder="Enter Your Father's name " type="text"></td>
           <td><input class="form-control"  placeholder="Enter Your Mobile  " type="text"></td>
           <td><a class="btn btn-danger del" href="#" >Delete</a></td>
       </tr>`;

     var table =  document.getElementById("tab");
     table.insertAdjacentHTML('beforeend',html );
})

document.addEventListener('click', function(event) {
           if (event.target.classList.contains('del')) {
               var row = event.target.closest('tr');
               row.remove();
           }
       });

       </script>
</body>
</html>

 


Share this article







Related Posts




0 Comments



Load more Comments

Post a Comment


helllo
Ocec Copyright text of dont't copyright our content