lundi 22 août 2016

HTML random number to text

I have this code. Which when you press "RUN" It prints a random number. I need some help (not sure where to start) to when it prints a random number it also prints text associated with that number. Example if it generates any number from 1-5 it will say "Hello" and if it generates 7 it will say "Wassup". Any help is appreciated.

<body>
 <script type="text/javascript">
       function RandomID() {
        var rnd = Math.floor(Math.random() * 11);
        document.getElementById('id').value = rnd;
   }
    </script>
<button class="button"onclick="RandomID();" style="font-family: sans-serif;">RUN</button>
<input class="input" type="text" id="id" name="id" size="3" readonly />
</body>
</html>

http://ift.tt/2baq0IQ




Aucun commentaire:

Enregistrer un commentaire