My site has a folder "images" with jpg images numbered 1-8 (1.jpg, 2.jpg etc.), an image tag, and also two canvases "nextPage" and "previousPage". what I'm trying to do is: when the "nextPage" canvas is clicked the image will change to the next image in the "images" folder, and when the "previousPage" is clicked the image will change to the previous image in the "images" folder. this is the code I've tried for the "nextPage" but the image doesn't change as it is supposed to.
<img id="image" src="Images/1.jpg" />
<canvas class=" navigation" id="nextPage" ></canvas>
<canvas class="navigation" id="formerPage"></canvas>
<script>
var currentPage = 1;
var lastPage = 8;
var firstPage = 1;
var btnNext = document.getElementById("nextPage");
btnNext.onclick = functionNext;
function functionNext() {
if (currentPage < lastPage) {
currentPage++;
document.getElementsById("image").src = "Images/" + currentPage + ".jpg";
}
}
</script>