Mega Code Archive

 
Categories / JavaScript Tutorial / Statement
 

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>