خرید بک لینک

Vote count: 0

I'm doing a website project for college and I want to display three pictures on website. There are 10 pictures stored in my folder (all named "slika 1 to 10" and the script has three variables, all of them randomly generate a number between 1 and 10 and then shows a picture "slika"+randomNumber.

How can I check if all three variables are different so that those three pictures are always different whenever I refresh the website.

JS code:

window.onload=odaberiSliku;

var broj1=Math.floor(Math.random() * 10) +1;
var broj2=Math.floor(Math.random() * 10) +1;
var broj3=Math.floor(Math.random() * 10) +1;

    function odaberiSliku() {
        document.getElementById("slika1").src = "slike/randomslike/slika"+broj1+".jpg";
        document.getElementById("slika2").src = "slike/randomslike/slika"+broj2+".jpg";
        document.getElementById("slika3").src = "slike/randomslike/slika"+broj3+".jpg";
    }

In case anyone wonders, the variable names are in croatian.

asked 3 mins ago

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 27 خرداد 1395 ساعت: 5:13

صفحه بندی