Jump to content

w3 slider - multiple sliders on one page


Recommended Posts

I have tried to implement multiple sliders on one page. The carousel function now get the respective slider name passed "carousel(slider)". The code is executed correctly, the function is being called by the time and the argument/object is correct. The display block/none property is set but anyway, the image does not change. Tried on IE, Edge, Chrome. What could I have done wrong?


<div class="container">
  <div class="w3-row">
    <div class="w3-third w3-container" align="center">
    <img src="http://media.bitronvideo.eu/b-home/bitronvideosito/interno3.png" width="300px">
    [maxbutton id="12"]
<img class="mySlides1" src="http://media.bitronvideo.eu/b-home/bitronvideosito/de.png">
<img class="mySlides1" src="http://media.bitronvideo.eu/b-home/bitronvideosito/it.png">
<img class="mySlides1" src="http://media.bitronvideo.eu/b-home/bitronvideosito/it.png">
  <div class="w3-third w3-container" align="center">
    <img src="http://media.bitronvideo.eu/b-home/bitronvideosito/interno2.png" width="300px">
    [maxbutton id="7"]
<img class="mySlides2" src="http://media.bitronvideo.eu/b-home/bitronvideosito/btouch11.png">
<img class="mySlides2" src="http://media.bitronvideo.eu/b-home/bitronvideosito/tline11.png">
   <div class="w3-third w3-container" align="center">
    <img src="http://media.bitronvideo.eu/b-home/bitronvideosito/interno1.png" width="300px">
    [maxbutton id="11"]
<img class="mySlides3" src="http://media.bitronvideo.eu/b-home/bitronvideosito/citofono1.png">
<img class="mySlides3" src="http://media.bitronvideo.eu/b-home/bitronvideosito/tclass1.png">
</div> <!-- chiusura container -->

.mySlides1 {display:none;}
.mySlides2 {display:none;}
.mySlides3 {display:none;}
<script type="text/javascript">
function carousel(slider)
    var slideIndex = 0;
    var i;
    var x = document.getElementsByClassName(slider);
    for (i = 0; i < x.length; i++) 
      x[i].style.display = "none"; 
    if (slideIndex > x.length) {slideIndex = 1} 
    x[slideIndex-1].style.display = "block"; 
    setTimeout(function(){carousel(slider);}, 2000); // Change image every 2 seconds


Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...