• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1165
  • Last Modified:

javascript switch with value ranges

How to specify javascript switch with value ranges?
0
Wally1964
Asked:
Wally1964
2 Solutions
 
basicinstinctCommented:
It doesn't really work that way in javascript (unlike vb's select case statement)...
However, you might find this useful...

http://www.thescripts.com/forum/post1687363-3.html
0
 
b0lsc0ttCommented:
Wally1964,

You can't specify a range but you can create a "list."  For example ...

switch (num) {
    case 1:
    case 2:
    case 3:
        // do this for either of the three;
        break;
    case 4:
    case 5:
        //  do this for 4 or 5;
        break;
}

Basicinstinct's post also has a clever way to possibly get what you want.  You might not even need this but in cases of a small range I have used the above.

Let me know if you have any questions or need more information.

b0lsc0tt
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now