Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Firstly here is the code link https://jsfiddle.net/jmd2f8xb/

Okay so the goal is for the JS to save the Radio Button Data To Local Storage and run the function "load" which loads the data back to the state it was saved in.

One of the things I need though is the html code that is there to still function even when JS is not enabled because all the JS needs to do is save and load.
I don't have enough skill to come up with the JS. Especially considering this is the only JS on the entire site so I was hoping someone could help me.

I did think of a way it could be done, I dont know how efficient and how good they are or how compatable they are with older browsers.
Add onclick to the html buttons which run a function that save the information.

What I have tried:

https://codepen.io/rajarajan/pen/XWVPRpX Only issue is it does not have a load function/someway to load it and I dont know how it could be implemented to function like my current method.

I tried modifying the above codepen into my code and changing stuff around and trying to make it duplicate the HTML and put it where it is meant to be and a bunch of other stuff I spent around 3 hours and now I am here. And the way that codepen was setup it replaced my HTML code which meant you could only switch colors with JS compared to how it is meant to be which is switch colors with CSS and only be able to save and load with JS
Posted
Updated 13-Apr-22 17:55pm

1 solution

Your jsfiddle had no javascript.

For load/save to local storage, This google search gives plenty of examples: javascript save load data to local storage[^] - this is a good link: localStorage in JavaScript: A complete guide - LogRocket Blog[^]

As for loading from storage when the page loads, you need to use: Window: load event - Web APIs | MDN</a>[^]
 
Share this answer
 
v2
Comments
Member 15601574 14-Apr-22 13:46pm    
I did not provide the JS because I never got it to work as intended.
Graeme_Grant 14-Apr-22 17:40pm    
Everything that you need is provided in the links posted above...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900