Advertisement
x-cisadane

Simpan dengan nama form.html di htdocs (XAMPP)

Oct 28th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.29 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <script src="http://localhost/jquery.min.js" type="text/javascript"></script>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  6. <script type="text/javascript">
  7.  
  8.     (function($){
  9.           $countForms = 1;
  10.           $.fn.addForms = function(){
  11.                 var myform = "<table>"+
  12.                  "  <tr>"+
  13.                  "     <td>Nama Orang ke-"+$countForms+":</td>"+
  14.                  "     <td><input type='text' name='fielda["+$countForms+"]'></td>"+
  15.                  "     <td>NPM Orang ke-"+$countForms+":</td>"+
  16.                  "     <td><textarea name='fieldb["+$countForms+"]'></textarea></td>"+
  17.                  "     <td><button>remove</button></td>"+
  18.                  "  </tr>"+
  19.                  "</table>";
  20.  
  21.                  myform = $("<div>"+myform+"</div>");
  22.                  $("button", $(myform)).click(function(){ $(this).parent().parent().remove(); });
  23.  
  24.                  $(this).append(myform);
  25.                  $countForms++;
  26.           };
  27.     })(jQuery);    
  28.  
  29.     $(function(){
  30.         $("#mybutton").bind("click", function(){
  31.             $("#container").addForms();
  32.         });
  33.     });
  34.  
  35. </script>
  36. </head>
  37. <body>
  38. <button id="mybutton">Tambah Lagi</button>
  39. <div id="container"></div>
  40. </body>
  41. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement