Here's my code:
<input id="numb" type="number" align="center">
<button type="button" onclick="myFunction()" align="center">Submit</button>
<p id="demo"></p>
<script>
function myFunction() {
var x, text;
// Get the value of the input field with id="numb"
x = document.getElementById("numb").value;
if (x == 1) {
text = "Fantasy World";
}
if (x == 2) {
text = "Sir Wags A Lot";
}
if (x == 3) {
text = "Take a Path";
}
if (x == 4) {
text = "River Clean Up"
}
if (x == 5) {
text = "Pinball"
}
if (x == 6) {
text = "Ghost Girl"
}
if (x == 7) {
text = "Dress Up"
}
if (x == 8) {
text = "Where Is My Hat?"
}
if (isNaN(x) || x < 1 || x > 8) {
text = "Input not valid";
}
document.getElementById("demo").innerHTML = text;
}
</script>
I need to make my code to give the user a button that confirms their order after entering a valid number into the input box.
For example:
if (x == 1) {
text = "Example"
}
then go from there to make another button that they can click to confirm that. Then they should be shown some text saying "confirmed order" - can anyone help me please? :)
if else.ifstatementsswitchstatement && tryx = parseInt(x);