Switch Statement 
Author Message
 Switch Statement

I appologize, but I'm new to JScript and can't seem to get this very simple switch statement to operate correctly.  It always passes right through to the default: sections.  Please help!

 sLocations = "ABCStores";

 switch (sLocations) {
      case 'ABCStores' :
           response.write("setting where for ABCStores<P>")
           sLocationsText = "ABC Stores"
           sWhere = " AND ((`tbl All Stores`.STORE_TYPE)='ABC' Or "
           sWhere = sWhere + "(`tbl All Stores`.STORE_TYPE)='BCD' Or "
           sWhere = sWhere + "(`tbl All Stores`.STORE_TYPE)='CDE')"
      case 'DEFStores' :
           sLocationsText = "DEF Stores"
           sWhere = " AND (`tbl All Stores`.STORE_TYPE)='DEF'"
      case 'GHIStores' :
           sLocationsText = "GHI Stores"
           sWhere = " AND (`tbl All Stores`.STORE_TYPE)='GHI'"
      case 'ABCDCs' :
           sLocationsText = "ABC DCs"
           sWhere = " AND (`tbl All Stores`.STORE_TYPE)='WT'"
      case 'DEFDCs' :
           sLocationsText = "DEF DCs"
           sWhere = " AND (`tbl All Stores`.STORE_TYPE)='WK'"
      case 'All' :
           sLocationsText = "All Locations"
           sWhere = ""
      default:
           response.write("defaulted in switch statement<P>")
           response.write("sLocations = " + sLocations + "<P>")
           response.write("Is it good = " + (sLocations == 'ABCStores') + "<P>")
  }



Mon, 06 May 2002 03:00:00 GMT  
 Switch Statement

Add "break" as the last statement in each case...

--
Michael Harris

  I appologize, but I'm new to JScript and can't seem to get this very simple switch statement to operate correctly.  It always passes right through to the default: sections.  Please help!

   sLocations = "ABCStores";

   switch (sLocations) {
        case 'ABCStores' :
             response.write("setting where for ABCStores<P>")
             sLocationsText = "ABC Stores"
             sWhere = " AND ((`tbl All Stores`.STORE_TYPE)='ABC' Or "
             sWhere = sWhere + "(`tbl All Stores`.STORE_TYPE)='BCD' Or "
             sWhere = sWhere + "(`tbl All Stores`.STORE_TYPE)='CDE')"
        case 'DEFStores' :
             sLocationsText = "DEF Stores"
             sWhere = " AND (`tbl All Stores`.STORE_TYPE)='DEF'"
        case 'GHIStores' :
             sLocationsText = "GHI Stores"
             sWhere = " AND (`tbl All Stores`.STORE_TYPE)='GHI'"
        case 'ABCDCs' :
             sLocationsText = "ABC DCs"
             sWhere = " AND (`tbl All Stores`.STORE_TYPE)='WT'"
        case 'DEFDCs' :
             sLocationsText = "DEF DCs"
             sWhere = " AND (`tbl All Stores`.STORE_TYPE)='WK'"
        case 'All' :
             sLocationsText = "All Locations"
             sWhere = ""
        default:
             response.write("defaulted in switch statement<P>")
             response.write("sLocations = " + sLocations + "<P>")
             response.write("Is it good = " + (sLocations == 'ABCStores') + "<P>")
    }



Mon, 06 May 2002 03:00:00 GMT  
 Switch Statement
Hi

Try with

case "ABCStores":
           Response.Write("setting where for ABCStores<P>")
          break
case "bla":
         Response.Write("setting where for bla<P>")
         break

--
Best Regards
   Vidar Petursson
http://www.icysoft.com


-

I appologize, but I'm new to JScript and can't seem to get this very simple
switch statement to operate correctly.  It always passes right through to
the default: sections.  Please help!

 sLocations = "ABCStores";

 switch (sLocations) {
      case 'ABCStores' :
           response.write("setting where for ABCStores<P>")
           sLocationsText = "ABC Stores"
           sWhere = " AND ((`tbl All Stores`.STORE_TYPE)='ABC' Or "
           sWhere = sWhere + "(`tbl All Stores`.STORE_TYPE)='BCD' Or "
           sWhere = sWhere + "(`tbl All Stores`.STORE_TYPE)='CDE')"
      case 'DEFStores' :
           sLocationsText = "DEF Stores"
           sWhere = " AND (`tbl All Stores`.STORE_TYPE)='DEF'"
      case 'GHIStores' :
           sLocationsText = "GHI Stores"
           sWhere = " AND (`tbl All Stores`.STORE_TYPE)='GHI'"
      case 'ABCDCs' :
           sLocationsText = "ABC DCs"
           sWhere = " AND (`tbl All Stores`.STORE_TYPE)='WT'"
      case 'DEFDCs' :
           sLocationsText = "DEF DCs"
           sWhere = " AND (`tbl All Stores`.STORE_TYPE)='WK'"
      case 'All' :
           sLocationsText = "All Locations"
           sWhere = ""
      default:
           response.write("defaulted in switch statement<P>")
           response.write("sLocations = " + sLocations + "<P>")
           response.write("Is it good = " + (sLocations == 'ABCStores') +
"<P>")
  }



Mon, 06 May 2002 03:00:00 GMT  
 
 [ 3 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