Add Textbox Dynamically using jQuery

Language
Hi sourcecodester, In this source code, you will learn on how to add TextBox dynamically using jQuery. You can also remove it. Hope this help. Sample code:
  1. <?php
  2. include('header.php');
  3. ?>
  4. <body>
  5. <script type="text/javascript">
  6. jQuery(document).ready( function () {
  7.  
  8.         $("#append").click( function() {
  9.                 $(".inc").append('<div class="controls"><input type="text"><a href="#" class="remove_this btn btn-danger">remove</a><br><br></div>');
  10.                 return false;
  11.         });
  12.        
  13.         jQuery('.remove_this').live('click', function() {
  14.                 jQuery(this).parent().remove();
  15.                 return false;
  16.         });
  17.        
  18.  
  19. });
  20. </script>
  21. <br>
  22. <br>
  23. <form class="form-horizontal">
  24.         <div class="control-group">
  25.                 <label class="control-label" for="inputEmail">TextBox</label>
  26.                 <div class="inc">
  27.                         <div class="controls">
  28.                                 <input type="text">
  29.                                 <button class="btn btn-info" type="submit" id="append" name="append">Add Textbox</button>
  30.                                 <br>
  31.                                 <br>
  32.                         </div>
  33.                 </div>
  34.         </div>
  35. </form>
  36. </body>
  37. </html>

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Comments

nice...you use append in adding element but how to add sql to this.???

Add new comment