Skip to content
Advertisement

Save and retrieve HTML table from localStorage

I am currently working on an app that will take data from multiple inputs, add it to an HTML table and store it to the local Storage as well. I am using HTML tables due to the fact that I wanted to implement the option to download the data as an XLSX file and for that I am using sheet.js which works with tables.

I managed to create the functions to take, store and show the data to the user but I am having a hard time with the ‘delete’ option. I would like the user to be able to delete each row but I am not sure how to update the local storage after an element is deleted.

Below is the code that I wrote for this app (please bear with me if it might look confusing but it just 1 month since I started learning Javascript).

JavaScript
JavaScript
JavaScript

I would much appreciate if someone can help with this problem that I am facing. Thank you

Advertisement

Answer

Whenever you store the row data in local storage then store it with some id like

JavaScript

So whenever you want to delete this then first get the value from local storage via this id and then you can delete it.

Advertisement