mercredi 20 mai 2015

Using math.random in button to set a select option?

I'm trying to make a button that randomly sets a select option when clicked. I can't figure out what I am doing wrong though...

http://ift.tt/1egIS4z

$('#rand').click(

        function() {
            randNum();
            var num = "";
            document.getElementById("mySelect").value.innerHTML = favWebComics[num];
    });

    var randNum = function() {
        num = Math.round(Math.random() * 2) + 1;
        return num;
    };

The shown code is only a small part of the larger script housed in the linked jsfiddle.

I plan to add more selections later, but I want to get the code figured out before I spend time on those.

Worth mentioning, my understanding of this is very limited, so keeping the advice simple is GREATLY appreciated.




Aucun commentaire:

Enregistrer un commentaire