?
Solved

Nested Switch Statements

Posted on 2003-04-01
2
Medium Priority
?
248 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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

801 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