I have an HTML table with buttons to add rows below the row where the button is selected. This table is populated from a SQL database. The idea (still working on the entire project) is to only update values where the button was clicked.
An example of the table structure:
When button on first row is selected:
The idea is to add a tick mark in the edit column where the button was clicked as well as the newly created row.
I am open to suggestions if there is another way to achieve this.
Comments
Comment posted by mplungjan
You now set the event handler in the function EVERY time it is called. That is not what you want. Move the click handler out of the function
Comment posted by evolutionxbox
Consider using event delegation.
Comment posted by mplungjan
Also it seems you insertBefore AND insertAfter
Comment posted by mplungjan
@evolutionxbox He is, just not correctly
Comment posted by mplungjan
You cannot have duplicate IDs
Comment posted by ben
Thanks for your code snippet. I have added my code in the snippet provided. You will see that there are no initial tick marks in the edit column until you click the split button. When clicking this button, I need the tick mark to show in the same line as well.
Comment posted by mplungjan
You still need to move the event handlers out.
Comment posted by mplungjan
I am using your HTML now – you need to explain the split button
Comment posted by ben
The best way to describe the aim of the split button is with a split bill at a restaurant. If you agree that the bill will be split in half, for example, you get one bill, but payment comes from two separate people. The descriptions will thus be different. Let’s say you click the split button on row 1, I need the tick mark on row 1 and the newly created row that will sit on row 2. When I update the database, the code will only check what was edited and only update/insert those records. Hope this gives more clarity.
Comment posted by mplungjan
I think I have given you enough code so you can fix your issue