Skip to content
Advertisement

Updating Table With User Information from Modal Popup

I am trying to update a row with just the name entered from a modal popup, where the user enters name, email, and phone-number. I attached an eventListener to the button Submit, that has a updateTable function that I am having a hard time understanding. I see that is grabs the data by table row with querySelectorAll, and loops through each cell with a “td” and does cell.innerText = name. How can I get this code to only change the cell clicked on by the user and now the whole row, which is does right now.

JavaScript

This is my logic so fare, the table is implemented as follows:

JavaScript

Any help would be appreciated.

EDIT: Here is the code for the modal.

JavaScript

Advertisement

Answer

I have updated the code. Instead of selecting the whole table row, you can select the td’s of the row and so to check which specific td is clicked in the row.

Also, you have defined the update table method in the for loop.

JavaScript
JavaScript
Advertisement