Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <script src="http://localhost/jquery.min.js" type="text/javascript"></script>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <script type="text/javascript">
- (function($){
- $countForms = 1;
- $.fn.addForms = function(){
- var myform = "<table>"+
- " <tr>"+
- " <td>Nama Orang ke-"+$countForms+":</td>"+
- " <td><input type='text' name='fielda["+$countForms+"]'></td>"+
- " <td>NPM Orang ke-"+$countForms+":</td>"+
- " <td><textarea name='fieldb["+$countForms+"]'></textarea></td>"+
- " <td><button>remove</button></td>"+
- " </tr>"+
- "</table>";
- myform = $("<div>"+myform+"</div>");
- $("button", $(myform)).click(function(){ $(this).parent().parent().remove(); });
- $(this).append(myform);
- $countForms++;
- };
- })(jQuery);
- $(function(){
- $("#mybutton").bind("click", function(){
- $("#container").addForms();
- });
- });
- </script>
- </head>
- <body>
- <button id="mybutton">Tambah Lagi</button>
- <div id="container"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement