The switch Statement : Switch « Language Basics « JavaScript DHTML






The switch Statement

  
<html>
<head>
  <title>The switch Statement</title>
</head>
<body>
  <script language="JavaScript1.2" type="text/javascript">
  <!--
    var request = "Name";
    switch(request){
      case "Logo" :
        document.write('<img src="logo.gif" alt="Logo">');
        document.write("<br>");
        break;
      case "Name" :        
        document.write("Software Inc.");
        document.write("<br>");
        break;
      case "Products" :
        document.write("MyEditor");
        document.write("<br>");
        break;
      default :
        document.write("www.java2s.com");
        break;
    }
  //-->
  </script>
</body>
</html>

           
         
    
  








Related examples in the same category

1.Switch statement
2.Another switch Statement
3. The switch Construction in Action
4.Use switch with true false value
5.Switch with string value
6.Switch based on integer value