Switch statement. 
Author Message
 Switch statement.

Hi!,
Tell me whats wrong with the following code.

var Sval = Request.Form("str_value")

Switch( Sval ){
  Case "page1":
    ...
  Case "page2":
    ...

Quote:
}

Even if sval is page1 doesnt execute the statements for Case "page1"
label

Thanks in advance,
-Ram

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Fri, 23 Aug 2002 03:00:00 GMT  
 Switch statement.
Hi

switch(Sval)
      case bla:
       ....
      break;

Mind the case...
--
Best Regards
 Vidar Petursson Microsoft MVP
http://www.icysoft.com


No matter where you go there you are
-

Quote:
> Hi!,
> Tell me whats wrong with the following code.

> var Sval = Request.Form("str_value")

> Switch( Sval ){
>   Case "page1":
>     ...
>   Case "page2":
>     ...
> }

> Even if sval is page1 doesnt execute the statements for Case "page1"
> label

> Thanks in advance,
> -Ram

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Fri, 23 Aug 2002 03:00:00 GMT  
 Switch statement.

Quote:
> Hi!,
> Tell me whats wrong with the following code.

> var Sval = Request.Form("str_value")

> Switch( Sval ){
>   Case "page1":
>     ...
>   Case "page2":
>     ...
> }

Hi,

'switch' is very sensitive to the argument you give it. You need to say:

    switch(String(SVal))
    {
    case "page1":
        // whatever
    }

This compares against a String value, which should give you the desired
result.

Peter

--
Peter J. Torr - Microsoft Windows Script Program Manager

Please do not e-mail me with questions - post them to this
newsgroup instead. Thankyou!



Mon, 26 Aug 2002 03:00:00 GMT  
 Switch statement.
I've found that I must use extra parens or I'm likely to get an [object]
object instead of a string object:

var Sval=Request.Form("str_value")();

Louis


Quote:
> Hi!,
> Tell me whats wrong with the following code.

> var Sval = Request.Form("str_value")

> Switch( Sval ){
>   Case "page1":
>     ...
>   Case "page2":
>     ...
> }

> Even if sval is page1 doesnt execute the statements for Case "page1"
> label

> Thanks in advance,
> -Ram

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Mon, 26 Aug 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Switch statement

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

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