Page 367 - Webapplication11_C11_Flipbook
P. 367

On running the above program, we get the following output:





















                 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");
                   }
                                                                                                  JavaScript Part 1  365
   362   363   364   365   366   367   368   369   370   371   372