Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8216197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:02:47+00:00 2026-06-07T12:02:47+00:00

i found on the Internet a plugin and add some new lines to form

  • 0

i found on the Internet a plugin and add some new lines to form this:

    (function($){

 $countForms = 1;
 $countFormsA = 1;

      $.fn.addForms = function(idform){

          var myform = "<table>"+
          "  <tr>"+
          "     <td>Field A ("+$countForms+"):</td>"+
          "     <td><input type='text' name='fielda["+$countForms+"]'></td>"+
          "     <td>Field B ("+$countForms+"):</td>"+
          "     <td><textarea name='fieldb["+$countForms+"]'></textarea></td>"+
          "     <td><button>remove</button></td>"+
          "  </tr>"+
          "</table>";

          var myform2 = "<table>"+
          "  <tr>"+
          "     <td>Field C</td>"+
          "     <td><input type='text' name='fieldc["+$countFormsA+"]'></td>"+
          "     <td>Field D ("+$countFormsA+"):</td>"+
          "     <td><textarea name='fieldd["+$countFormsA+"]'></textarea></td>"+
          "     <td><button>remove</button></td>"+
          "  </tr>"+
          "</table>";

    if(idform=='mybutton'){
       alert(idform);
       myform = $("<div>"+myform+"</div>");
$("button", $(myform)).click(function(){ $(this).parent().parent().remove(); });
$(this).append(myform);
$countForms++;
}
    else{

    if(idform=='mybutton1'){
       alert(idform);
    myform2 = $("<div>"+myform2+"</div>");
$("button", $(myform2)).click(function(){ $(this).parent().parent().remove(); });
    $(this).append(myform2);

    $countFormsA++;

                        }
                    }                     
      };

})(jQuery);         

 $(function(){
    $("#mybutton1").bind("click", function(){

    var idform=this.id;

        if($countFormsA<3){
            $("#container1").addForms(idform);
        }       
    });
});

$(function(){
    $("#mybutton").bind("click", function(){

    var idform=this.id;

        if($countForms<3){
            $("#container").addForms(idform);
        }       
    });
});

However i’m having a problem. If i click “add form” everything works, but when i click “add form 1” the new form is added but after 1 second it disappears. Any hint how can i solve this? Thank you!

The html code:

<button id="mybutton">add form</button>
<div id="container"><div>
<form method="post" name="b" >
<table>
    <tr>
        <td>Field A</td>
        <td><input type='text' name='dadoA'></td>
        <td>Field B</td>
        <td><textarea name="dadoB"></textarea></td>
                             <td><button>remove</button></td>
                          </tr>
                         </table></div></div>

                         <div align="center">
<p><input type="submit" value="Registar" name="registar"></p>
</div>
<!-- -->

<button id="mybutton1">add form1</button>
<div id="container1"><div>
<form method="post" name="a" >
<table>
    <tr>
        <td>Field A</td>
        <td><input type='text' name='dadoA'></td>
        <td>Field B</td>
        <td><textarea name="dadoB"></textarea></td>
                             <td><button>remove</button></td>
                          </tr>
                         </table></div></div>

                         <div align="center">
<p><input type="submit" value="Registar1" name="registar1"></p>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:02:49+00:00Added an answer on June 7, 2026 at 12:02 pm

    The form will disappear because the page is being refreshed by that button’s default behaviour.

    You will need to prevent that behaviour in your click binding. I would suggest passing the event object through and using preventDefault() ie:

    $("#mybutton1").bind("click", function(e){
        e.preventDefault();
        var idform=this.id;
    
        if($countFormsA<3){
            $("#container1").addForms(idform);
        }       
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is some code I found on the internet. I'm not sure how it
I found some mapkit code on the internet that looks like this: - (void)recenterMap
I've found this code in the internet: $.tablesorter.addWidget({ id: memorizeSortOrder, format: function(table) { if
I am trying to write the simples GUI countdown. I found in Internet some
I have little question. I found this on internet: Type t = typeof(MyClass); MethodInfo[]
I found this code in the internet and I modified it for my use,
I have found some code snippet in the internet. But it is missing some
Few months ago I started some experiments with jQuery plugin. I found some tutorials
I'm using the following example I found on the internet to dynamically build a
I'm looking to test my app on iPad via WiFi, in internet I found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.