Page 324 - Web Applications (803) Class 11
P. 324
When you click on the “OK” button, with the message “This page says”. Then a new window appears as shown below:
Example: Write the program to select the subject by user using switch statement.
<!DOCTYPE HTML>
<HTML>
<HEAD>
<TITLE> Switch Statement </TITLE>
</HEAD>
<BODY>
<SCRIPT>
var choice = parseInt(prompt("Please select the Subject: Enter 1 for Hindi / 2 for
English"));
switch(choice)
{
case 1:
document.write("You selected Hindi");
break;
case 2:
document.write("You selected English");
break;
default:
document.write("You selected wrong subject");
}
</SCRIPT>
</BODY>
</HTML>
Output:
Example:
<HTML>
<BODY>
<SCRIPT>
var fav_food = prompt("Enter Your favourite food");
document.write("Favourite Food Entered:"+fav_food+"<br> <br>");
switch (fav_food) {
case "pizza": document.write("Pizza is 350 rupees<br>");
break;
322 Touchpad Web Applications-XI

