Possible Duplicate:
Storing Objects in HTML5 localStorage
I'm trying to store JSON data, name & phonenumber given in two text fields and then later(after page refresh) retrieve and print the data on the same fields with following code.
function saveData() {
var saveD = {
name: document.getElementById("name").value,
phone: document.getElementById("phone").value
};
window.localStorage.setItem("info", saveD);
}
var storedData = window.localStorage.getItem("info");
document.getElementById("name").value = storedData.name;
document.getElementById("phone").value = storedData.phone;
What is wrong? I get "undefined" on both fields.