lundi 21 août 2017

Random changing generator

I have some problems here.

a)I would like to set the 3-8 characters,but it only show 3 characters.

b)I would like to have three output with different display time.Do I only nid to create different Id?

Anyone can help? What's wrong with this code? Thanks.

Javascript

        function randomString(Length)
        {
        if(Length < 3) Length = 3;
        if(Length > 8) Length = 8;
            var text = "";
            var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            for( var i=0; i < Length; i++ )
                text += possible.charAt(Math.floor(Math.random() * possible.length));

            return text;
        }

        function ChangingRandomString(Length)
        {
            setInterval(function(){document.getElementById("random").style.fontSize = Math.floor((Math.random() * 20) + 10)+"px",
                document.getElementById("random").innerHTML = randomString(Length);
            },2000);
        }




Aucun commentaire:

Enregistrer un commentaire