Switch statement : JavaScript DHTML examples (example source code) » Language Basics » Switch

JavaScript DHTML










Java Products
Java Articles
JavaScript DHTML Home  »   Language Basics   » [  Switch  ]   

 
Switch statement

Please note that some example is only working under IE or Firefox.

/* Note that Sunday=0, Monday=1, Tuesday=2, etc.*/

<html>
<body>
<script type="text/javascript">
var d = new Date()
theDay=d.getDay()
switch (theDay){
  case 5:
    document.write("Finally Friday")
  break
  case 6:
    document.write("Super Saturday")
  break
  case 0:
    document.write("Sleepy Sunday")
  break
  default:
    document.write("Not weekend!")
}
</script>


</body>
</html>
Related examples in the same category
1.  The switch Statement
2.  Another switch Statement
3.   The switch Construction in Action








Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.