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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:50:50+00:00 2026-06-05T08:50:50+00:00

I have an html table in my webpage. It is filled with information from

  • 0

I have an html table in my webpage. It is filled with information from my database.

It has this structure:

Id- Title –Author
1 – Africa – John Smith
2- Europe- Martin Coole

The table is inside a form and has an “Add More” button.

When you hit that button a modal window shows and you can append another title-author row to the table using:

//inside of the addRow function
    $('#myTable').append(“<tr><td>..”);

The table also has an edit and delete button for each row. The onclick has:

//For the edit button
 editRow(id, value1, value2);
//For the delete button
 deleteRow(id);

And here comes my problem, the ids.

The info coming from the database has a solid id (1 and 2) but how should I deal with the ids of the rows appended with the “Add More” button?

What I have done so far is getting the last id from the database rows and put it in a hidden field in my table then in my js file:

var lastID = $('#lastID').val();
var i = 1;
var newId = parseInt (lastID)+i;

newId is 3 and this is valid if one row is appended but if a second row is appended via the “Add More” button I have 3 in newId again :((

How can I fix this? How can I add consecutive ids to the newly appended rows?

  • 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-05T08:50:52+00:00Added an answer on June 5, 2026 at 8:50 am

    In your function editRow write:

    var lastID = $('#lastID').val();
    
    // Do your insertion stuff
    // ...
    
    // After insertion, raise lastID by 1
    $('#lastID').val(++lastID);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a HTML table like this: <table border=1> <tbody> <tr> <td><a href=# class=delete>DELETE
I have a HTML table like this: <table border=1> <tbody> <tr> <td><a href=# class=delete>DELETE
I have an html table containing values that are being generated from javascript. How
I have an HTML table filled with a number of rows. How can I
I have an HTML table on a webpage and can edit the contents manually.
I am making webpage where data from database are put in a table. Each
I have HTML table in my webPage. I have applied css to that table.
I have one webpage (lets call it A.html). A.html has some javascript which switches
I have a mysql table. I have created a html table and filled it
So I have this webpage built that has a photo gallery on the left

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.