Switch statement 
Author Message
 Switch statement

Can anyone tell me how to use the switch to select between a range:

     switch (variable)
     {
      case 10-20:         //This statement does not work
       Y.value = "10";
       break;



Mon, 23 Jun 2003 18:32:38 GMT  
 Switch statement

Quote:
> Can anyone tell me how to use the switch to select between a range:
>      switch (variable)
>      {
>       case 10-20:         //This statement does not work
>        Y.value = "10";
>        break;

AFAIK, you can't.
But how about something like this.

var val = variable/10;
switch(val) {
   case 1:
   case 2:
      Y.value = "10";
      break;

Of course that only works if you have steps of 10. Otherwise you need if
and else if.

Regards
   Adi



Mon, 23 Jun 2003 18:41:04 GMT  
 Switch statement
switch (true)
{
    case variable > 9 && variable < 21
        Y.value = '10';
        break;

Quote:
}


| Can anyone tell me how to use the switch to select between a range:
|
|      switch (variable)
|      {
|       case 10-20:         file://This statement does not work
|        Y.value = "10";
|        break;
|
|


Mon, 23 Jun 2003 19:45:45 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Switch statement won't work! (JS/ASP)

2. switch statement

3. Switch statement.

4. Switch Statement

5. switch statement

6. can any one tell me why this switch statement will only work once

7. Switch statement and the toLowerCase()

8. Switch Statement

9. switch statement problem

10. Help!!! JScript Switch Statement Does not work on Active Server Page

11. VBS equivilent to JScript 'switch' statement

12. Switch case statement

 

 
Powered by phpBB® Forum Software