<script>
document.getElementById("clicker").onclick = function () {
var scenario = document.getElementById('scenario');
switch (scenario) {
case 1:
document.getElementById("answer").innerHTML = "How are you?";
break;
case 2:
document.getElementById("answer").innerHTML = "whatevers";
break;
case 3:
document.getElementById("answer").innerHTML = "i don't know";
break;
case 4:
document.getElementById("answer").innerHTML = "today is your lucky day";
break;
default:
document.getElementById("answer").innerHTML = "This is the worst case scenario";
}
}
</script>
<input type="text" id="scenario" />
<input type="submit" id="clicker" />
<p id="answer"></p>
So here i'm trying to basically have a text field where the user will type in some value based on that value, the script will then look at cases and determine what to output in the paragraph element.
Please advise how i should correct this code.