Jump to content

Recommended Posts

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)">&#10094;</a>
  					<a class="next" onclick="plusSlides(1, 0)">&#10095;</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)">&#10094;</a>
  					<a class="next" onclick="plusSlides(1, 1)">&#10095;</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)">&#10094;</a>
  					<a class="next" onclick="plusSlides(1, 2)">&#10095;</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

Share this post


Link to post
Share on other sites

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";  
}

 

 

Share this post


Link to post
Share on other sites

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 by dsonesuk

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...