+ 5
How can I have the Javascript input data into sessionStorage?
Heeeeeelllllllppppppp.....
4 Answers
+ 2
Well, why use sessionStorage, so?
The first link I've previously posted said:
SesÂsionÂStorÂage
- PerÂsists a storÂage area for the duraÂtion of the page sesÂsion.
- Use it when you need to store some data temÂporarÂily. A page sesÂsion impleÂmenÂtaÂtion might be difÂferÂent based on browser venÂdor and its version.
- Data is available as long as the browser is open, includÂing page reloads and restoresIt gets deleted the time when the tab/window who creÂated the sesÂsion is closed
LocalÂStorÂage
- PerÂsists the data until the user explicÂitly deletes the data.
- Use it when you need to store some data for the long term.
- Data is available even after the browser is closed and reopened
LocalStorage maybe? As you want display the location by an alert, I guess you would like to store the value for acceding to it in another session/page ( sessions in this context have not same meaning as sessions in Php ^^ )... Anyway, always from the first link:
The folÂlowÂing examÂple shows the native getÂter and setÂter methÂods for localÂStorÂage. SimÂiÂlar methÂods do exist for sesÂsionÂStorÂage as well:
// setterlocal
Storage.setItem("employeeName", "Ryan");
localStorage.setItem("employeeId", 121456789);
// getter
var name = localStorage.getItem("employeeName"); // Ryan
var id = localStorage.getItem("employeeId"); // 121456789
Do you also need help for getting location? :P
+ 4
what i want to do is have the js find the coderunner's location, input it into sesionStorage, then tell the code runner their location in the form of an alert
+ 2
That's just web pages with essentially textual informations ^^
If you want more precise help, on a particular topic, be less vagueless, show/explicit your code context... We cannot guess enough to much more good targeting a right answer.
+ 1
Firstly you need to well known differences between sessionStorage and localStorage object:
http://javascript.tutorialhorizon.com/2015/09/08/getting-started-with-localstorage-vs-sessionstorage-in-html5/
Next, you can look at some courses/tuto's:
http://tutorials.jenkov.com/html5/local-storage.html
http://html5.litten.com/html5-web-storage-using-localstorage-and-sessionstorage-objects/
https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API
And finally dive into references to grow up your skills:
http://www.w3schools.com/html/html5_webstorage.asp
https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API
https://developer.mozilla.org/fr/docs/Web/API/Window/localStorage
https://developer.mozilla.org/fr/docs/Web/API/Window/sessionStorage
... abd do the same kind of google searches to get information on how to retrieve data from html <input> elements whith JS ^^