<input type="button" id="btnSearch" value="Search" onclick="myFunction();" />
<div id="message">
<p></p>
</div>
<br>
<div id="message">
<p></p>
</div>
<script type="text/javascript">
function myFunction() {
var myarray= new Array ("Drama", "Fable", "Fairy Tale", "Fantasy", "Fiction", "Folklore", "Historical Fiction", "Horror", "Humor", "Mystery", "Mythology", "Poetry", "Realistic Fiction", "Science Fiction", "Short Story", "Tall Tale");
var random = myarray[Math.round(Math.random() * (myarray.length - 1))]
var display = document.getElementById("message").innerHTML=random;
}
</script>
I have this so far and what I'm trying to do is have one button click display two random words from my array next to each other. Thanks in advance for the help!
Aucun commentaire:
Enregistrer un commentaire