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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:23:53+00:00 2026-05-16T23:23:53+00:00

I have a table in which i append rows on onclick event, the row

  • 0

I have a table in which i append rows on onclick event, the row has a button which enables you to delete it … this works fine. The problem comes when i have inserted some rows e.g 5 rows, and i delete any row btwn the 1st and last row then add two consecutive rows , the last row is duplicated with the counter value of the previous row.

my question is, how do i get to get the value of the final row appended so i can increment it to any row i add without creating duplicate values

here is the code

HTML

<form action = '' method = 'post' id = 'resume_form'>        

<table id="work" width="100%" border="0" cellspacing="0" cellpadding="0" style="color:#FFFFFF" >
  <tr bgcolor="#0000FF">
    <td width="4%">&nbsp;</td>
    <td width="76%"><strong>PARTICULARS</strong></td>
    <td width="20%"><strong>AMOUNT</strong></td>   
  </tr>
</table>               
<input type="button" id="button"  value="Add field" / >
</form>

JS

<script type="text/javascript">

    $('#button').click(function(){
        var count = $('input.dasa').length;
                //Html to create a new field       

              '<tr class = "work_experiance' + count + '">' +
                '<td></td>' +
                '<td><input class=\'dasa\' type="text" name="part' + count + '" id="part' + count + '" /></td>' +
                '<td><input type="text" name="amount' + count + '" id="amount' + count + '" /</td>' +

            '<td><input class="remove_project_file" onclick="del(\''+count+'\')"  type = "button"  id = "delete' + count + '" name = "delete' + count + '" onclick="del(' + count + ')" value="delete' + count + '">' +
            '</tr>';
        $('#work').append(newFields);
    });
    $('form').submit(function() {
        $.post('resume.php', $(this).serialize(),
            function(data) { alert(data); });
        return false;
    });


function del(count)
{
var count;
    if(count=='0')
    {
        $('#delete'+count+'').attrib('disabled','');
    }
    else
    {
        $('.work_experiance' + count + '').remove();
    }

}

</script>
  • 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-05-16T23:23:53+00:00Added an answer on May 16, 2026 at 11:23 pm

    Get your count from the last field instead, like this:

     var count = parseInt($('input.dasa:last').attr('id').replace('part',''),10) + 1;
    

    This grabs the :last <input class="dasa" id="partNNN" /> and gets the count out of it by removing the "part" prefix then praseInt() on what’s left. Then we’re just adding 1 to that result for creating the next row.

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

Sidebar

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.