r/programminghelp • • Aug 10 '19

[JS] localStorage help

function save() {

document.getElementById("deets").innerHTML = "saving your settings..."

document.getElementById("loading").style.display = 'block'

if (document.getElementById("lang").value === "en") {localStorage.setItem("lang", "en")}

if (document.getElementById("theme").value === "T1") {localStorage.setItem("theme", "T1")}

if (document.getElementById("theme").value === "T2") {localStorage.setItem("theme", "T2")}

document.getElementById("deets").innerHTML = ""

document.getElementById("loading").style.display = 'none'

document.getElementById("settings").style.display = 'none'

document.getElementById("successSettings").style.display = 'block'

setTimeout(function () {

	document.getElementById("successSettings").style.display = 'none'

}, 3000);

}

function applySettings() {

document.getElementById("deets").innerHTML = "applying settings..."

document.getElementById("loading").style.display = "block";

if (localStorage.getItem("lang") === "en") {document.getElementById("lang").value = "en"}

if (localStorage.getItem("theme") === "T1") {document.getElementById("theme").value = "T1";}

if (localStorage.getItem("theme") === "T2") {document.getElementById("theme").value = "T2"; whiteMode();}

document.getElementById("loading").style.display = "none";

}

Is there anything wrong with this code? I've been trying it for a while through Firefox and it won't save the cookies :/

4 Upvotes

7 comments sorted by

View all comments

Show parent comments

1

u/Silicon_Folly Aug 27 '19

... do you mean in the dev tools? Like viewing where you can see console, elements, etc

1

u/[deleted] Aug 27 '19

yeah.

1

u/[deleted] Aug 27 '19

update: turns out i made a few typos in the HTML file, my bad.

1

u/Silicon_Folly Aug 27 '19

Haha it's all good, it happens. Glad you got it sorted out!