Switch statement with return value from a prompt dialog : Switch : Statement JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Statement » Switch »

 

Switch statement with return value from a prompt dialog

















<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
<!--
var yourchoice;
yourchoice = prompt("Choose a number between 1 and 4""1, 2, 3 or 4")
switch (yourchoice)
{
    case "1":
        alert("You typed in a 1");
        break;
    case "2":
        alert("You typed in a 2");
        break;
    case "3":
        alert("You typed in a 3");
        break;
    case "4":
        alert("You typed in a 4");
        break;
}
//  -->
</script>
</head>
<body>

</body>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Statement
» Switch