Use switch with true false value : Switch « Language Basics « JavaScript DHTML






Use switch with true false value

  

<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
var yourchoice;
yourchoice = confirm("True of false")
switch (yourchoice)
{
    case true:
        alert("true!");
        break;
    case false:
        alert("false");
        break;
}   
</script>
</head>
<body>

</body>
</html>

   
    
  








Related examples in the same category

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