Javascript buttons

Hello there. I need some help here

in the picture above I’m trying to take data from this simple form and check whether they’re valid or not. when I Click Save Button if they are valid I display data in a table, actually, this table is not hidden it’s created from scratch in js code and contains data from the form.
as shown in the pic I took data and displayed them in the table but there are two buttons here (update, delete) if delete is clicked the whole row is deleted and if update is clicked it’s replaced by two buttons (save, cancel) and the data fields turn to text boxes so I can change them and click save or click cancel if I Want to leave them as they’re. but I have some issues when I click update button the two buttons(save, cancel) replace it and if I Clicked cancel or save the update button returns back the issue here is that when I click on update button again it’s not working. can some help me?
I’ll attach the js code file so that anyone can take a look and tell me what I’m missing.
code link(