Advertisement
kangjaz

form_dinamis

Dec 15th, 2018
2,316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 2.77 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <meta charset="utf-8" />
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <title>Form Dinamis</title>
  7.     <meta content="width=device-width,initial-scale=1" name=viewport>
  8.     <link rel="stylesheet" type="text/css" media="screen" href="./assets/css/bootstrap.min.css" />
  9. </head>
  10. <body>
  11.    
  12.     <div class="container">
  13.  
  14.         <div class="row">
  15.  
  16.             <div class="col-md-8 col-md-offset-2">
  17.  
  18.                 <h4 style="text-align: center; margin-top:20px">Form Dinamis by Kangjaz.Com</h4>
  19.                 <hr />
  20.  
  21.                 <table class="table table-striped">
  22.                     <thead>
  23.                         <tr>
  24.                             <th>Nama Anggota</th>
  25.                             <th>Alamat</th>
  26.                             <th>No. Telp</th>
  27.                             <th>Opsi Form</th>
  28.                         </tr>
  29.                     </thead>
  30.  
  31.                     <tbody id="form-body">
  32.                         <tr>
  33.                             <td>
  34.                                 <input type="text" class="form-control" name="nama[]" placeholder="Nama Anggota">
  35.                             </td>
  36.                             <td>
  37.                                 <input type="text" class="form-control" name="alamat[]" placeholder="Alamat">
  38.                             </td>
  39.                             <td>
  40.                                 <input type="text" class="form-control" name="hp[]" placeholder="Telp">
  41.                             </td>
  42.                             <td>
  43.                                
  44.                             </td>
  45.                         </tr>
  46.                     </tbody>
  47.                 </table>
  48.  
  49.                 <button type="button" onclick="add_form()" class="btn btn-success">Tambah Form</button>
  50.             </div>
  51.  
  52.         </div>
  53.        
  54.     </div>
  55.     <!-- load jquery -->
  56.     <script src="./assets/js/jquery.min.js"></script>
  57.     <!-- Custom JavaScript -->
  58.     <script type="text/javascript">
  59.         function add_form()
  60.         {
  61.             var html = '';
  62.  
  63.             html += '<tr>';
  64.             html += '<td><input type="text" class="form-control" name="nama[]" placeholder="Nama Anggota"></td>';
  65.             html += '<td><input type="text" class="form-control" name="alamat[]" placeholder="Alamat"></td>';
  66.             html += '<td><input type="text" class="form-control" name="hp[]" placeholder="Telp"></td>';
  67.             html += '<td><button type="button" class="btn btn-danger" onclick="del_form(this)">Hapus</button></td>';
  68.             html += '</tr>';
  69.  
  70.             $('#form-body').append(html);
  71.         }
  72.  
  73.         function del_form(id)
  74.         {
  75.             id.closest('tr').remove();
  76.         }
  77.     </script>
  78. </body>
  79. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement