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 8910823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:47:12+00:00 2026-06-15T03:47:12+00:00

I have a form that will have dynamic elements inserted with javascript and am

  • 0

I have a form that will have dynamic elements inserted with javascript and am experiencing some strange behavior. When I click the button to add another element to the table in the form, it adds the element but seems to to a form post immediately (without intending to submit the form yet)

I have created a simplified example of the page that has the same behavior. the first table element is created on page load and subsequent elements are added when clicking on the button. this form works successfully in IE. does anyone have an idea of how to prevent this behavior?

here is the code sample.

<!DOCTYPE html>
<html>
<head>
    <title>Test Creating Form</title>
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
    <style type="text/css">
        td{font-family:verdana;}
    </style>
    <script type="text/javascript">
        var counter = 0;

        function makeTitle(title){
            if(counter){
                title += " " + counter;
            }
            counter++;
            var tbl = document.getElementById('tbl');
            var tr = tbl.insertRow(-1)
            var td1 = tr.insertCell(-1);
            td1.innerHTML = title;
        }


        function load1(){
            makeTitle('Primary Specimen');
        }
    </script>
</head>
<body onload="load1();">
    <form action="formtest.htm" method="post" name="testForm" id="testForm">
        <table id="tbl" border="1"></table>
        <button onclick="makeTitle('Alternate Specimen')" id="clone" >Add Another Specimen</button>


    </form>
</body>
</html>
  • 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-15T03:47:13+00:00Added an answer on June 15, 2026 at 3:47 am

    Button tags default to type="submit"; add type="button".

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a simple form that when you click the save button will
Javascript I have code that will hide various sections in a MS CRM form
I have a form that needs to be dynamic, allowing the user to add
I have a form containing some dynamic elements. These are basically text input boxes
The functionality I'm looking for: I have a form that will search my 'Proposal'
I have a windows form that has two DataGridViews (DGVs) that will hold 25,000+
(Using MySQL and PHP) I have a search form that will allow my users
I have a form in my application that will fill using Unicode characters (Non
I have created a form with knockout that will allow the ability to give
I have a form with a hidden Came from Adwords field that will be

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.