Click to See Complete Forum and Search --> : Equivalent to Case Statement in VB


Webskater
01-12-2004, 10:01 AM
Can anyone tell me if there is an equivalent in Javascript to the VB Case Statement.
e.g.
Select Case Anyvalue
Case 1,5,9
Okay
Case 2,3,4,6,7,8
Not Okay
END Select
Thanks for any help

fredmv
01-12-2004, 10:08 AM
switch(foo)
{
case 1:
case 5:
case 9:
// code
break;

case 2:
case 3:
case 4:
case 6:
case 7:
case 8:
// code
break;
} http://devedge.netscape.com/library/manuals/2000/javascript/1.4/guide/stmtsov.html#1008329

Webskater
01-12-2004, 10:33 AM
Thanks for your answer (and for your answer to my question a few days ago about scrolling to make an object visible).

Is there a way of putting all the criteria on one line?

Like

case 1,5,9

Thanks again.

fredmv
01-12-2004, 10:37 AM
No problem. As for your question, I don't believe so; you'll have to write the code as I've done so above.