[Javascript] select-case construct

Muchacho, Laurent (TWIi London) LMuchacho at twii.net
Mon Oct 29 14:09:39 CST 2001


Yes you can but in javascript it be called switch 

switch (i) {
   case "Oranges" : 
      document.write("Oranges are $0.59 a pound.<BR>"); 
      break; 
   case "Apples" : 
      document.write("Apples are $0.32 a pound.<BR>"); 
      break; 
   case "Bananas" : 
      document.write("Bananas are $0.48 a pound.<BR>"); 
      break; 
   case "Cherries" : 
      document.write("Cherries are $3.00 a pound.<BR>"); 
      break; 
   default : 
      document.write("Sorry, we are out of " + i + ".<BR>"); 
} 
document.write("Is there anything else you'd like?<BR>");

there is a link with a really good references
http://developer.netscape.com/docs/manuals/js/client/jsref/index.htm


Laurent

-----Original Message-----
From: Esther_Strom at hmco.com [mailto:Esther_Strom at hmco.com]
Sent: 29 October 2001 19:59
To: javascript at LaTech.edu
Subject: [Javascript] select-case construct


I'm sure this has been mentioned before, but I can't find the message or an
example in any of my books. Can you use a select-case construct in
javascript?

Pseudocode example:

select case prodStatus

Case "New"
//do this

Case "In Progress"
//do this

Case else
//do this

End select

Thanks for any help available.

Esther

_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
http://www.LaTech.edu/mailman/listinfo/javascript



More information about the Javascript mailing list