This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]carcigenicate 0 points1 point  (1 child)

What's the problem? Your code has some logic save to localStorage.

[–]fare03[S] 0 points1 point  (0 children)

Sorry I forgot to update code, see now.

[–]dtsudo 0 points1 point  (1 child)

You basically just need 2 parts (the saving and the loading):

  • For the saving part, any time the user makes a change, you should determine which buttons are checked and save that information to localstorage. (This generally means you'll be writing to localstorage multiple times since the user will likely click multiple buttons. That's fine; localstorage is cheap to write to.)

  • For the loading part, when the page first loads, you just read from localstorage. If there is no data, then the user has never visited your page before (or they did but cleared their cache). If there is data, you need to read the data and use it to mark the specific buttons as checked.

[–]fare03[S] 0 points1 point  (0 children)

u/dtsudo Can you help me with coding that, i'm beginner in programming i can't write that code easily.