Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Nested Switch Statements

Posted on 2003-04-01
2
Medium Priority
?
257 Views
Last Modified: 2008-02-01
Can you have nested switch statements?

Example:

switch(search1)
{
  case "case1":
    switch(search2)
    {
      case "caseA":
        alert("Case A");
        break;
      case "caseB":
        alert("Case B");
        break;
    }
   case "case2":
     alert("Case 2");
     break;
}
0
Comment
Question by:andichilds
2 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 1000 total points
ID: 8246579
don't see why not although, you are missing the break in case "case1"

switch(search1)
{
  case "case1":
    switch(search2)
    {
      case "caseA":
        alert("Case A");
        break;
      case "caseB":
        alert("Case B");
        break;
    }
    break;
   case "case2":
     alert("Case 2");
     break;
}
0
 

Author Comment

by:andichilds
ID: 8246606
Thanks, i was a muppet not to notice!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question