In an older post listed below it explained how to create a next button that clicked index to page2, then page3, then back to index as a loop. older post link
The code I found useful is:
var pageList = ["index.html", "01.html", "02.html"];
var url = window.location.pathname; // e.g. http://me.com/index.html
var page = url.substring(url.lastIndexOf('/')+1); // e.g. index.html
var currentPosition = pageList.indexOf(page); // e.g. 0, 1 or 2
document.getElementById('next-btn').onclick = function(){
// if the URL is not in the list, do nothing
if(currentPosition==-1) return;
// if we're at the end, go back to index, else, go to next page
window.location = currentPosition<pageList.length-1? pageList[++currentPosition]:pageList[0];
}
BUT, the "Previous" button code did not work, so I tried this:
document.getElementById('prev-btn').onclick = function(){
if(currentPosition==-1) return;
window.location = currentPosition<pageList.length-1? pageList[++currentPosition]:pageList[0];
}
I want to change that final code so it functions accurately so it clicks backward to each previous page 5-4-3-2-1 etc.