Search code examples
javascriptsavebackendsaving-data

How to allow user to make changes to JSON array


I'm currently working on my first real world application meant to make my lead's job at work a little easier. I volunteered to do it to challenge myself and try to learn new things, as I am new and need real world challenges to help me grow.

What I'm doing is building a browser based application using HTML, CSS, and Javascript (nothing fancy) and automate our crew rotation at work.

I have a working prototype, which was not difficult to write, the rotation function works as I envisioned when I first came up with this idea.

I have this prototype live online here: https://chillaxin-cyborg.neocities.org/Upstairs%20Crew%20Rotation%20(prototype)/Crew%20Rotation%202.html

Please excuse the styling, I haven't focused much on that as of yet (more concerned with functionality at the moment).

My question is what do I need to do in order to:

  1. allow my lead to save the current rotation when he clicks the rotate button (rather than having the array revert back to its original order)

  2. allow my lead to add or remove crew members and have those changes save as well.

I am guessing that I need to be using some kind of back-end technology for this to happen, right? Or is there another method I can use? I would like for this application to work offline, if at all possible.

Thank you


Solution

  • You can use the browser's localstorage API to persist data across sessions, this won't work across computers though, that would require some backend work. Unfortunately for you, working with localstorage is a bit more tricky when using vanilla javascript as some libraries can be used to abstract the hard stuff away from you. here's some documentation to get you started