Hello guys I have a question. I have made a calendar and everything works, but the last requirement is to add dates through localStorage.
So my question: how can I add more dates without overwriting the first one?
I was thinking about getting the data out, add the new testObject, and put it back to localStorage. The only thing is I have no clue how to do it.
I hope someone can help. ( I am quite a beginner )
So in short, I want to put more than one array into the events-array through localStorage.
This is my code:
<script language="JavaScript" type="text/javascript" >
testObject = ["Y", prompt("maand"), prompt("dag"), "2000", prompt("test"), prompt("test")]
retrievedObject = localStorage.getItem('testObject');
// Put the object into storage
localStorage.setItem('testObject', JSON.stringify(testObject))
events = new Array(
JSON.parse(retrievedObject),
["Y", "1", "1", "2000", "Nieuw jaars dag", "De eerste dag van het nieuw Jaar"],
["Y", "7", "3", "2000", "Mijn verjaardag", "beste dag van het jaar"],
["Y", "17", "10", "2000", "Inleverdag", "Ergste dag van het jaar."]
);
</script>
Edit : after I add 2 arrays it should Work like this But the upper 2 values should be retrieved form local storage and if I add another one it should be 3 arrays in the local storage. But the local storage overwrites itself everytime So at the moment I am only able to add 1 array
events = new Array(
["Y", "1", "2", "2000", "test", "test"],
["Y", "2", "4", "2000", "test2", "test3"],
["Y", "1", "1", "2000", "Nieuw jaars dag", "De eerste dag van het nieuw Jaar"],
["Y", "7", "3", "2000", "Mijn verjaardag", "beste dag van het jaar"],
["Y", "17", "10", "2000", "Inleverdag", "Ergste dag van het jaar."]
);
eventsto be? Can you edit the question and output the computed value you'd like to see?