To be able to save data in an array and then access this data different pages of your web site you will need to use local storage. Local storage stores data for a lifetime in the broswer and will be useful for many applications. More information can be found online - https://www.w3schools.com/jsref/prop_win_localstorage.asp
Create a JS script file.
Create an empty array that will store your planned data set
Check to make sure there is no existing data set already stored with the same key in local storage.
If not populate your local array variable with the stored data.
This script will need to run at the start of each page. Note that an array variable will need to be parsed using Json to be able to read as a normal array structure.
people is the name of the array and data is the name of storage value key where the contents of the people array is stored in memory.
var people = [];
if (localStorage.getItem('data')) {
people = JSON.parse(localStorage.getItem('data'))
}
You can then create functions to read and write to the array and store in the memory of the browser
function addPerson(){
var p = document.getElementById("person").value;
people.push(p);
localStorage.setItem("data",JSON.stringify(people));
location.href = "page1.html";
}
function print(){
for(var i = 0; i< people.length;i++){
document.getElementById("print").innerHTML += people[i]+"<br>";
}
}