I want to know what code to use to create a form where the user can input something and click submit (or a button) and the data will be stored in an array (or JSON object) , then they can do it again and the previous data will be "pushed" hence the user can keep adding to it. This would continue so on and so forth. I am also interested if "local storage" can be used to store this information on the users machine.
This question is a continuation of a question I had here: Add form input to array with javascript using unshift()
Below is some code. This code does what I want but only with one input item.
Thank you.
<form>
<input id="input" type="text"/>
<button id="button"> Click me </button>
</form>
<script>
var input = document.getElementById("input"); // save the object
var button = document.getElementById("button");
var myArray = [];
button.onclick = function alerted (){
myArray.unshift(input.value); // get the value
alert(myArray);
return false;
};
</script>
localStorage.