alex.gutowski Posted April 26, 2020 Share Posted April 26, 2020 I am following the tutorial here, and I would like to add more than two slideshows on a page. I tried this: <h4>10 Shot Photo Challenge #1</h4> <div class="slideshow-container"> <div class="mySlides1"> <div class="numbertext">1 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotone/Gutowski_BlackAndWhite.jpg" style="width:100%"> </div> <div class="mySlides1"> <div class="numbertext">2 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotone/Gutowski_Contrast.jpg" style="width:100%"> </div> <div class="mySlides1"> <div class="numbertext">3 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotone/Gutowski_Emotion.jpg" style="width:100%"> </div> <div class="mySlides1"> <div class="numbertext">4 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotone/Gutowski_FavoriteColor.jpg" style="width:100%"> </div> <div class="mySlides1"> <div class="numbertext">5 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotone/Gutowski_Misc.jpg" style="width:100%"> </div> <div class="mySlides1"> <div class="numbertext">6 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotone/Gutowski_Numbers.jpg" style="width:100%"> </div> <div class="mySlides1"> <div class="numbertext">7 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotone/Gutowski_Outside.jpg" style="width:100%"> </div> <div class="mySlides1"> <div class="numbertext">8 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotone/Gutowski_Rule_of_Thirds.jpg" style="width:100%"> </div> <div class="mySlides1"> <div class="numbertext">9 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotone/Gutowski_StartingWithB.jpg" style="width:100%"> </div> <div class="mySlides1"> <div class="numbertext">10 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotone/Gutowski_UpClose.jpg" style="width:100%"> </div> <a class="prev" onclick="plusSlides(-1, 0)">❮</a> <a class="next" onclick="plusSlides(1, 0)">❯</a> </div> <br> <br> <h4>10 Shot Photo Challenge #2</h4> <br> <div class="slideshow-container"> <div class="mySlides2"> <div class="numbertext">1 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshottwo/Gutowski_happy.JPG" style="width:100%"> </div> <div class="mySlides2"> <div class="numbertext">2 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshottwo/Gutowski_January.JPG" style="width:100%"> </div> <div class="mySlides2"> <div class="numbertext">3 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshottwo/IMG_2873.JPG" style="width:100%"> </div> <div class="mySlides2"> <div class="numbertext">4 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshottwo/IMG_2931.JPG" style="width:100%"> </div> <div class="mySlides2"> <div class="numbertext">5 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshottwo/IMG_2985.JPG" style="width:100%"> </div> <div class="mySlides2"> <div class="numbertext">6 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshottwo/IMG_2986.JPG" style="width:100%"> </div> <div class="mySlides2"> <div class="numbertext">7 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshottwo/IMG_3031.JPG" style="width:100%"> </div> <div class="mySlides2"> <div class="numbertext">8 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshottwo/IMG_3037.JPG" style="width:100%"> </div> <div class="mySlides2"> <div class="numbertext">9 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshottwo/IMG_3041.JPG" style="width:100%"> </div> <div class="mySlides2"> <div class="numbertext">10 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshottwo/IMG_E3040.JPG" style="width:100%"> </div> <a class="prev" onclick="plusSlides(-1, 1)">❮</a> <a class="next" onclick="plusSlides(1, 1)">❯</a> </div> <br> <br> <h4>10 Shot Photo Challenge #3</h4> <br> <div class="slideshow-container"> <div class="mySlides3"> <div class="numbertext">1 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotthree/IMG_0139.JPG" style="width:100%"> </div> <div class="mySlides3"> <div class="numbertext">2 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotthree/IMG_0144.JPG" style="width:100%"> </div> <div class="mySlides3"> <div class="numbertext">3 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotthree/IMG_0157.JPG" style="width:100%"> </div> <div class="mySlides3"> <div class="numbertext">4 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotthree/IMG_0158.JPG" style="width:100%"> </div> <div class="mySlides3"> <div class="numbertext">5 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotthree/IMG_0159.JPG" style="width:100%"> </div> <div class="mySlides3"> <div class="numbertext">6 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotthree/IMG_0160.JPG" style="width:100%"> </div> <div class="mySlides3"> <div class="numbertext">7 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotthree/IMG_0192.JPG" style="width:100%"> </div> <div class="mySlides3"> <div class="numbertext">8 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotthree/IMG_0199.JPG" style="width:100%"> </div> <div class="mySlides3"> <div class="numbertext">9 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotthree/IMG_0936.JPG" style="width:100%"> </div> <div class="mySlides3"> <div class="numbertext">10 / 10</div> <img alt="this is required and i dont want to put this" src="multimedia/tenshotthree/IMG_0945.JPG" style="width:100%"> </div> <a class="prev" onclick="plusSlides(-1, 2)">❮</a> <a class="next" onclick="plusSlides(1, 2)">❯</a> </div> <script> var slideIndex = [1,1]; var slideId = ["mySlides1", "mySlides2", "mySlides3"] showSlides(1, 0); showSlides(1, 1); showSlides(1, 2); 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"; } x[slideIndex[no]-1].style.display = "block"; } </script> This made 2 slideshows, but the third one didn't work. How can I get a third slideshow onto this webpage? ZIP file attached with all website files. 10shot.html is the file I am having trouble with. Alex's Website.zip Link to comment Share on other sites More sharing options...
dsonesuk Posted April 27, 2020 Share Posted April 27, 2020 You have added extra value for each slideshow but the slideIndex. Link to comment Share on other sites More sharing options...
Weazly Posted May 28, 2020 Share Posted May 28, 2020 I have the same problem. It shows the first two Slideshows with picture and arrow, but the third one shows only the arrows. HTML: <p>Slideshow 1:</p> <div class="slideshow-container"> <div class="mySlides1"> <img src="../03-bilder/halle/IMG_1.jpg" class="slide"> </div> <div class="mySlides1"> <img src="../03-bilder/halle/IMG_2.jpg" class="slide"> </div> <div class="mySlides1"> <img src="../03-bilder/halle/IMG_3.jpg" class="slide"> </div> <a class="prev" onclick="plusSlides(-1, 0)">❮</a> <a class="next" onclick="plusSlides(1, 0)">❯</a> </div> <p>Slideshow 2:</p> <div class="slideshow-container"> <div class="mySlides2"> <img src="../03-bilder/Turnier1/IMG_1.jpg" class="slide"> </div> <div class="mySlides2"> <img src="../03-bilder/Turnier1/IMG_2.jpg" class="slide"> </div> <div class="mySlides2"> <img src="../03-bilder/Turnier1/IMG_3.jpg" class="slide"> </div> <div class="mySlides2"> <img src="../03-bilder/Turnier1/IMG_4.jpg" class="slide"> </div> <a class="prev" onclick="plusSlides(-1, 1)">❮</a> <a class="next" onclick="plusSlides(1, 1)">❯</a> </div> <p>Slideshow 3:</p> <div class="slideshow-container"> <div class="mySlides3"> <img src="../03-bilder/end-of-summer/IMG_1.jpg" class="slide"> </div> <div class="mySlides3"> <img src="../03-bilder/end-of-summer/IMG_2.jpg" class="slide"> </div> <div class="mySlides3"> <img src="../03-bilder/end-of-summer/IMG_3.jpg" class="slide"> </div> <div class="mySlides3"> <img src="../03-bilder/end-of-summer/IMG_4.jpg" class="slide"> </div> <a class="prev" onclick="plusSlides(-1, 2)">❮</a> <a class="next" onclick="plusSlides(1, 2)">❯</a> </div> CSS: .mySlides1, .mySlides2, .mySlides3 {display: none} img {vertical-align: middle;} /* Slideshow container */ .slideshow-container { max-width: 1000px; position: relative; margin: auto; } /* Next & previous buttons */ .prev, .next { cursor: pointer; position: relative; top: 50%; width: auto; padding-right: 8vw; padding-left: 8vw; color: white; font-weight: bold; font-size: 8vw; transition: 0.6s ease; border-radius: 0 3px 3px 0; user-select: none; } /* Position the "next button" to the right */ .next { right: 0; border-radius: 3px 0 0 3px; } /* On hover, add a grey background color */ .prev:hover, .next:hover { background-color: #f1f1f1; color: black; } Javascript: var slideIndex = [1,2]; var slideId = ["mySlides1", "mySlides2", "mySlides3"] showSlides(1, 0); showSlides(1, 1); showSlides(1, 2); 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] = 2} if (n < 2) {slideIndex[no] = x.length} for (i = 0; i < x.length; i++) { x[i].style.display = "none"; } x[slideIndex[no]-2].style.display = "block"; } Link to comment Share on other sites More sharing options...
dsonesuk Posted May 28, 2020 Share Posted May 28, 2020 (edited) The Problem is the same. 1) You have 3 slideshows, All index references MUST reflect you now have 3; <div class="slideshow-container"> <div class="mySlides3"> <img src="../03-bilder/end-of-summer/IMG_1.jpg" class="slide"> </div> <!--DONE--> <div class="mySlides3"> <img src="../03-bilder/end-of-summer/IMG_2.jpg" class="slide"> </div> <!--DONE--> <div class="mySlides3"> <img src="../03-bilder/end-of-summer/IMG_3.jpg" class="slide"> </div> <!--DONE--> <div class="mySlides3"> <img src="../03-bilder/end-of-summer/IMG_4.jpg" class="slide"> </div> <!--DONE--> <a class="prev" onclick="plusSlides(-1, 2)">❮</a> <!--DONE--> <a class="next" onclick="plusSlides(1, 2)">❯</a> <!--DONE--> </div> var slideId = ["mySlides1", "mySlides2", "mySlides3"]; //DONE showSlides(1, 0); //DONE showSlides(1, 1); //DONE showSlides(1, 2); //DONE BUT! var slideIndex = [1,2]; //FAIL : FOR EACH SLIDESHOW THERE MUST BE A VALUE and NO! 1 + 2 does not count as the third slideshow use: .slideshow-container div[class^="mySlides"]{ display: none} it will be easier than adding every slideshow class Edited May 28, 2020 by dsonesuk Link to comment Share on other sites More sharing options...
Joaquin Uliambre Posted June 2, 2020 Share Posted June 2, 2020 I do not understand, how is the code solved? Link to comment Share on other sites More sharing options...
dsonesuk Posted June 2, 2020 Share Posted June 2, 2020 Quite easily really, but I'll explain yet! Again! var slideIndex = [1,2]; Only has array of slideshow indexes of two values, which means 2 values = 2 slideshows, slideIndex = [1,1] 3 values = 3 slideshows, slideIndex = [1,1,1] 4 values = 4 slideshows, slideIndex = [1,1,1,1] 5 values = 5 slideshows, slideIndex = [1,1,1,1,1] 6 values = 6 slideshows, slideIndex = [1,1,1,1,1,1] 7 values = 7 slideshows, slideIndex = [1,1,1,1,1,1,1] 8 values = 8 slideshows, slideIndex = [1,1,1,1,1,1,1,1] 9 values = 9 slideshows, slideIndex = [1,1,1,1,1,1,1,1,1] Do you really want me to continue? Get the drift? 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