Click here to Skip to main content
15,905,587 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The problem is that I'm getting the first set of slideshow but not the other two. But all the dots below the slideshows are working perfectly.

What I have tried:

<html>
<head>
<h2>Cheapest Hotels in Goa:</h2>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {box-sizing: border-box;}
.mySlides {display: none;}
.Slides2 {display: none;}
.Slides3 {display: none;}

/* Slideshow container */
.slideshow-container {
width: 600px;
  position: relative;
  margin: auto;
}
/* Slideshow container */
.slideshow-pictures {
width: 600px;
  position: relative;
  margin: auto;
}
/* Slideshow container */
.slideshow-images {
width: 600px;
  position: relative;
  margin: auto;
}
    
/* The dots/bullets/indicators */
.dot {
  height: 15px;
  width: 15px;
  margin: 0 2px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.6s ease;
}
/* The dots/bullets/indicators */
.tod {
  height: 15px;
  width: 15px;
  margin: 0 2px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.6s ease;
}
/* The dots/bullets/indicators */
.odt {
  height: 15px;
  width: 15px;
  margin: 0 2px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.6s ease;
}
.active {
  background-color: #717171;
}

/* Fading animation */
.fade {
  -webkit-animation-name: fade;
  -webkit-animation-duration: 2.5s;
  animation-name: fade;
  animation-duration: 1.5s;
}

@-webkit-keyframes fade {
  from {opacity: .4} 
  to {opacity: 1}
}

@keyframes fade {
  from {opacity: .4} 
  to {opacity: 1}
}

</style>
</head>
<body>
<div class="slideshow-container">

<div class="mySlides fade">
  <img src="mdq.jpg" style="width:100%">
</div>

<div class="mySlides fade">
  <img src="mdq0.jpg" style="width:100%">
</div>
<div class="mySlides fade">
  <img src="mdq1.webp" style="width:100%">
</div>

<div class="mySlides fade">
  <img src="mdq2.webp" style="width:100%">
</div>
    
<div class="mySlides fade">
  <img src="mdq3.jpg" style="width:100%">
</div>
<div class="mySlides fade">
  <img src="mdq4.webp" style="width:100%">
</div>
</div>
<br>

<div style="text-align:center">
  <span class="dot"></span> 
  <span class="dot"></span> 
    <span class="dot"></span> 
    <span class="dot"></span> 
    <span class="dot"></span> 
    <span class="dot"></span> 
</div><br><br>

<div class="slideshow-container">

<div class="Slides2 fade">
  <img src="pal.jpg" style="width:100%">
</div>

<div class="Slides2 fade">
 <img src="pal0.jpg" style="width:100%">
</div>
<div class="Slides2 fade">
 <img src="pal1.jpg" style="width:100%">
</div>

<div class="Slides2 fade">
    <img src="pal2.jpg" style="width:100%"></div>
    
<div class="Slides2 fade">
 <img src="pal3.webp" style="width:100%">  
</div>
<div class="Slides2 fade">
 <img src="pal4.webp" style="width:100%">  
</div>
</div>
<br>

<div style="text-align:center">
  <span class="tod"></span> 
  <span class="tod"></span> 
    <span class="tod"></span> 
    <span class="tod"></span> 
    <span class="tod"></span> 
    <span class="tod"></span> 
</div><br>

<div class="slideshow-container">
    
<div class="Slides3 fade">
    <img src="oyo.webp"></div>
<div class="Slides3 fade">
    <img src="oyo0.jpg"></div>
<div class="Slides3 fade">
    <img src="oyo1.webp"></div>
<div class="Slides3 fade">
    <img src="oyo2.webp"></div>
<div class="Slides3 fade">
    <img src="oyo3.webp"></div>
<div class="Slides3 fade">
    <img src="oyo4.webp"></div><br>

<div style="text-align:center">
  <span class="odt"></span> 
  <span class="odt"></span> 
  <span class="odt"></span> 
  <span class="odt"></span> 
  <span class="odt"></span> 
  <span class="odt"></span> 
</div>
<script>
var slideIndex = 0;
showSlides();

function showSlides() {
  var i;
  var slides = document.getElementsByClassName("mySlides", "Slides2", "Slides3");
  var dots = document.getElementsByClassName("dot", "tod", "odt");
  for (i = 0; i < slides.length; i++) {
    slides[i].style.display = "none";  
  }
  slideIndex++;
  if (slideIndex > slides.length) {slideIndex = 1}    
  for (i = 0; i < dots.length; i++) {
    dots[i].className = dots[i].className.replace(" active", "");
  }
  slides[slideIndex-1].style.display = "block";  
  dots[slideIndex-1].className += " active";
  setTimeout(showSlides, 2000); // Change image every 2 seconds
}
</script>
</body>
</html> 
Posted
Updated 12-Nov-19 10:18am

Maybe you can use the: JQuery Cycle Plugin[^]
 
Share this answer
 
Hi
You can use Bootstrap Carousel in your page instead of this code. This Bootstrap plugin provides great feature for slide show and we don't have to do too much code. so it will save your time. I will suggest you to use this plugin.

Please check this link: https://www.w3schools.com/bootstrap/bootstrap_carousel.asp
Hope This will help you.
Thank you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900