shmoonkiepoonks Posted June 13, 2019 Share Posted June 13, 2019 I like the automatic slideshow in the example here: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_slideshow_auto, but would like 2 slideshows on one page. When I try to do this myself, one slideshow plays and finishes, then the other one starts and finishes. I would like them to start at the same time and loop and like the caption option but don't necessarily need the "dots". Link to comment Share on other sites More sharing options...
justsomeguy Posted June 13, 2019 Share Posted June 13, 2019 For that example, the easiest way would be to use different class names for your other slideshow. So use mySlides2 and dots2, for example, and make a copy of that Javascript code with a different function to run the second slideshow with the other class names. 1 Link to comment Share on other sites More sharing options...
shmoonkiepoonks Posted June 14, 2019 Author Share Posted June 14, 2019 (edited) I got it to work using your suggestion. Thank you. Edited June 14, 2019 by shmoonkiepoonks Link to comment Share on other sites More sharing options...
MondoDopeness Posted June 27, 2019 Share Posted June 27, 2019 Can anyone elaborate on this? I'm good with HTML & CSS - but have hardly any experience using JS - I was able to get the 2 slideshows working, and they were able to be clicked left and right to the new slides, however, wanting to change these 2 slideshows to automatic has been a headache. I have made the changes the moderator suggested, changing the 2nd slide show class names mySlides2 and dots2... but don't know where to go from here... I don't understand how to make a "different function to run the second slideshow with the other class names." Thank you for any response. Here is where I am at: <script> var slideIndex = 0; showSlides(); function showSlides() { var i; var slides = document.getElementsByClassName("mySlides1"); var dots = document.getElementsByClassName("dot"); for (i = 0; i < slides.length; i++) { slides.style.display = "none"; } slideIndex++; if (slideIndex > slides.length) {slideIndex = 1} for (i = 0; i < dots.length; i++) { dots.className = dots.className.replace(" active", ""); } slides[slideIndex-1].style.display = "block"; dots[slideIndex-1].className += " active"; setTimeout(showSlides, 2000); // Change image every 2 seconds}</script> <script>var slideIndex = 0;showSlides(); function showSlides() { var i; var slides = document.getElementsByClassName("mySlides2"); var dots = document.getElementsByClassName("dot2"); for (i = 0; i < slides.length; i++) { slides.style.display = "none"; } slideIndex++; if (slideIndex > slides.length) {slideIndex = 1} for (i = 0; i < dots.length; i++) { dots.className = dots.className.replace(" active", ""); } slides[slideIndex-1].style.display = "block"; dots[slideIndex-1].className += " active"; setTimeout(showSlides, 2000); // Change image every 2 seconds}</script> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now