I am trying to create a random quotes generator based on TV shows. After user selects a show and hits Submit button, the program should display a random quote depending on selected TV series. All quotes are located in their arrays.
My code is below. Would you please help me understand why it is not working and how to fix it?
<!DOCTYPE html>
<html>
<body>
<h3>A demonstration of how to access a SELECT element</h3>
<select id="mySelect" size="2">
<option value="1">Suits</option>
<option value="2">Supernatural</option>
</select>
<p>Click the button to select the show and display a random quote.</p>
<button onclick="myFunction();">Submit</button>
<p id="demo"></p>
<script>
function myFunction() {
var suits = new Array("Specter is fat", "Ross is fat", "Pearsonis fat", "Litt is fat", "Zane is fat");
var supernatural = new Array("Dean is fat", "Sam is fat", "Castiel is fat");
var x = document.getElementById("mySelect").value;
switch (x) {
case 1:
var quote = suits[Math.floor(Math.random()*suits.length)];
document.getElementById("demo").innerHTML = quote;
break;
case 2:
var quote = supernatural[Math.floor(Math.random()*supernatural.length)];
document.getElementById("demo").innerHTML = quote;
break;
};
}
</script>
</body>
</html>