M
M
Messi2015-03-19 13:13:42
Slider
Messi, 2015-03-19 13:13:42

Display images in a slider?

Hello! slider question:

var map_main;
var secDuration = 200;
var image = 1;
var maxImages = 4;
var timeout;

//jQuery(document).ready(function(){
    function changeImage(requiredImage) {

        if (!requiredImage && requiredImage != 0){
            if(image < maxImages){
                image++;
            }
            else{
                image = 1;
            }
        }
        else{
            if(requiredImage > maxImages){
                image = 1;
            }
            else if(requiredImage < 1){
                image = maxImages;
            }
            else{
                image = requiredImage;
            }
        }

        slider.className = "image"+image;

        clearTimeout(timeout);
        timeout = setTimeout("changeImage()",secDuration*1000);
    }


    function nextImage(){
        changeImage(image+1);
    }
    function prevImage(){
        changeImage(image-1);
    }

    changeImage(1);

//});

The slider works like this, at the beginning of the script, the maximum number of images in the slider is indicated, if there is no image there, then it shows an empty background (but scrolls like a photo).
Please tell me what needs to be added to the code so that, for example, 10 photos are allowed, and only 3 are uploaded, then let it display only 3, and not scroll through all 10 items.
thank!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question