Reputation: 85
Hai I want to get javascript value using LocalStorage and stored a value in php. I don't know how to set a value so kindly provide me the solution.
var getdate1 = document.getElementById("eventDayName").innerHTML = selectedDate.toLocaleString("en-US", {
month: "long",
day: "numeric",
year: "numeric"
});
localStorage.getItem('getdate1', val);
Upvotes: 1
Views: 2712
Reputation: 143
Use this code:
// Store
localStorage.setItem("lastname", "Smith");
//get
localStorage.getItem("lastname");
Upvotes: 2
Reputation: 4915
For set a value in localStorage use window.localStorage.setItem
like
window.localStorage.setItem('getdate1', JSON.stringify(getdate1));
var getdate1 =document.getElementById("eventDayName").innerHTML = selectedDate.toLocaleString("en-US", {
month: "long",
day: "numeric",
year: "numeric"
});
window.localStorage.setItem('getdate1', JSON.stringify(getdate1));
Upvotes: 2