Introduction
I have 2 simple slideshows on a single page. Only one works. Please help.
I did research on how to develop a simple sideshow and it worked at first
But then i added another slideshow and it went out of wacko
My Code
//slideshow-pokeballs.js
var images = ["https://img.rankedboost.com/wp-content/uploads/2016/07/PokeBall.png", "https://img.rankedboost.com/wp-content/uploads/2016/07/Great-Ball.png", "https://img.rankedboost.com/wp-content/uploads/2016/07/Ultra-Ball.png", "https://img.rankedboost.com/wp-content/uploads/2016/07/Master-Ball.png"];
var imageNumber = 0;
var imageLength = images.length - 1;
function changeBall(x) {
imageNumber += x;
document.getElementById("pokeballs").src = images[imageNumber];
return false;
}
//slideshow-pokemon.js
var imageNumber = 0;
var imageLength = images.length - 1;
var images = ["https://vignette.wikia.nocookie.net/pokemon/images/2/21/001Bulbasaur.png/revision/latest/scale-to-width-down/200?cb=20140328190757", "https://vignette.wikia.nocookie.net/pokemon/images/7/73/004Charmander.png/revision/latest/scale-to-width-down/200?cb=20140724195345", "https://vignette.wikia.nocookie.net/pokemon/images/3/39/007Squirtle.png/revision/latest/scale-to-width-down/200?cb=20140328191525"];
function changeMon(x) {
imageNumber += x;
document.getElementById("pokemon").src = images[imageNumber];
return false;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>
<body>
<div>
<img src="https://img.rankedboost.com/wp-content/uploads/2016/07/PokeBall.png" id="pokeballs" />
<br>
<a href="#" onclick="changeBall(-1); return false;">Previous Slide</a>
<a href="#" onclick="changeBall(1); return false;">Next Slide</a>
<script src="js/slideshow-pokeballs.js"></script>
</div>
<br>
<div>
<img src="https://vignette.wikia.nocookie.net/pokemon/images/2/21/001Bulbasaur.png/revision/latest/scale-to-width-down/200?cb=20140328190757" id="pokemon" />
<br>
<a href="#" onclick="changeMon(-1); return false;">Previous Slide</a>
<a href="#" onclick="changeMon(1); return false;">Next Slide</a>
<script src="js/slideshow-pokemon.js"></script>
</div>
</body>
What i would like
1)I would like to know how to make both slideshows work on the same page and possibly add more slideshows to the page.
2)I hope that the solution i have is a simple change, i don't want to go off-course with the original idea that i had here.