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

  • SEARCH
  • Home
  • 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 8443075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:02:03+00:00 2026-06-10T09:02:03+00:00

I have a table, where each row corresponds to a form. While the markup

  • 0

I have a table, where each row corresponds to a form. While the markup is invalid (<form> tags come after <tr> immediately), submit buttons work as expected (ie. they submit their containing form). So far, so good.

Now I prepare a new row to be appended to the table mentioned above. It resides hidden in a separate table. When the ‘Add a year’ button pressed, I clone the tr with the form and append it to the table. But here comes the suprise: the newly created submit button does not submit. (I tried the same without cloning, makes no difference.)

Here are the code snippets (included in a JSFiddle):

HTML

<div id="min" style="display:none">2010</div>

<div id="div_newyr" style="display:none">
<table>
    <tr>
<form action="" method="post" name="form1" id="form1">
        <td class="td_yr">
            <span></span>
            <input type="hidden" name="yr" value="" />
        </td>
        <td><input type="submit" name="sub_close" value="Close" /></td>
</form>
    </tr>
</table>
</div>

<table>
<tbody id="tb_yrs">
    <tr>
<form action="" method="post" name="form2" id="form2">
        <td class="td_yr last">
            <span>2010</span>
            <input type="hidden" name="yr" value="2010" />
        </td>
        <td><input type="submit" name="sub_close" value="Close" /></td>
</form>
    </tr>

</tbody>
<tbody>    
    <tr>
        <td><input type="button" id="but_newyr" value="Add a year" /></td>
    </tr>
</tbody>
</table>

JS

jQuery(document).ready(function() {
    $('#but_newyr').click(function() {
        var firstYear = parseInt($('div#min').html());
        firstYear--;
        newRow = $('#div_newyr').find('tr').clone(true);
        newRow.find('td.td_yr').children('span').html(firstYear).next('input').val(firstYear);

        $('#tb_yrs').append(newRow);
        $('div#min').html(firstYear);
    });
});

//added on a tip from a deleted answer
$(document).on('click', "input[type=submit]" ,function(){
    $(this).closest('form').submit();
});

If I make the to-be-cloned form visible in order to check whether it works before cloning, I can submit that form. So, the question is: what is the difference between the original and the appended/cloned form or submit button?

(Just a sidenote: the appended row begins in line with the second cell under Chrome – but I think it has nothing to do with the submit.)

  • 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-10T09:02:05+00:00Added an answer on June 10, 2026 at 9:02 am

    Try

    $(this).closest('tr').find('form').submit();
    

    instead of

    $(this).closest('form').submit();
    

    but better would be to avoid invalid markup, and either:

    1. Don’t use a table for layout
    2. Don’t use form elements – use jQuery to serialize and submit the rows on demand
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with two radio buttons for each row, these buttons are
I have a table where each row has a description field as well as
I have a table where each row has 13 TD elements. I want to
I have a table column where each row has one of three states, and
I have a employee table, and a vacations table where each row represents a
I have a table with many rows and each row has select lists. Something
I have a SQL table where in each row I store the country and
I have a table with multiple rows in each row is a select list
I have a DB table in which each row has a randomly generated primary
I have a data table filled with text in each table row. How do

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.