May 2021 2 94 Report
How can I change order of images in slideshow when user refreshes website?

Right now on my current website, I have it going through the pictures in the order of the array, but I would like it so whenever the user refreshes the website, the slideshow randomly shuffles the pictures in a different order.

<script type="text/javascript">

var imgs = [

'images/slideshow/001.jpg',

'images/slideshow/002.jpg',

'images/slideshow/003.jpg',

'images/slideshow/004.jpg',

'images/slideshow/005.jpg',

'images/slideshow/006.jpg'];

var cnt = imgs.length;

$(function() {

setInterval(Slider, 3000);

});

function Slider() {

$('#imageSlide').fadeOut("slow", function() {

// the source of the problem

$(this).attr('src', imgs[Math.floor (Math.random( ) * imgs.length) % cnt]).fadeIn("slow");

});

}

</script>

Any help is appreciated! =]


Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments




Helpful Social

Copyright © 2024 Q2A.MX - All rights reserved.