Currently, I am exploring the W3 HTML/CSS tutorial on incorporating multiple slideshows into a single page. While the tutorial provides examples for manual navigation of multiple slideshows or a single automatic slideshow, it lacks guidance on setting up multiple automatic slideshows. In an attempt to merge these concepts, ensuring that each slideshow retains its unique index, I encountered difficulty achieving seamless automatic transitions.
If you're interested in the W3 tutorial, you can access it here: https://www.w3schools.com/howto/howto_js_slideshow.asp(https://www.w3schools.com/howto/howto_js_slideshow.asp)
Below is the snippet of code where I tried to modify the implementation to enable automated transitioning of slides:
var slideIndex = [1,1];
/* Assign different CSS classes to members of each slideshow group */
var slideId = ["mySlides1", "mySlides2"]
showSlides(1, 0);
showSlides(1, 1);
function plusSlides(n, no) {
showSlides(slideIndex[no] += n, no);
}
function showSlides(n, no) {
var i;
var x = document.getElementsByClassName(slideId[no]);
if (n > x.length) {slideIndex[no] = 1}
if (n < 1) {slideIndex[no] = x.length}
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
n++; /* MY INSERTION */
x[slideIndex[no]-1].style.display = "block";
setTimeout(showSlides(n, x), 2000); /* MY ADDITION */
}
The capitalized comment beside the code line signifies my modification to the original tutorial code. Despite experimenting with setInterval and rearranging code blocks, I have yet to achieve the desired functionality.