2
I am making a form and I want to store the data that the client enters in the browser cache, in case the tab is closed the client does not need to type everything again.
What is the best means to meet this need?
2
I am making a form and I want to store the data that the client enters in the browser cache, in case the tab is closed the client does not need to type everything again.
What is the best means to meet this need?
3
You can use Webstorage of an Object, such as localStorage of the fields:
imagine that you have two fields of input one with ID = name
and another ID = lastname
you can do localstorage of these fields thus:
var lastname = document.getElementById("lastname").value;
var name = document.getElementById("name").value;
localStorage.setItem("lastname", lastname);
localStorage.setItem("name", name);
where the first part within the parentheses represents the name of the "attribute" of localStorage, and can be referenced by localStorage.lastname
/ localStorage.name
Thanks for the answer, man, it helped me a lot!
1
Beyond the localStorage, also exists the sessionStorage (https://www.w3schools.com/html/html5_webstorage.asp), which turns out to be more secure, since it’s session-based, and complemented with an authentication system, it can be time-controlled
Browser other questions tagged javascript html
You are not signed in. Login or sign up in order to post.
Related: Differences between localStorage Vs sessionStorage?
– Barbetta
Yes, in the comment below he gave me the example of localStorage, but how they work and which the best?
– LuisHF
Take a look question I added, I believe answer your question
– Barbetta