SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Case If

  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2002
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Case If

    Just wondering how the JS sytax of this goes,

    I've been looking around and I can't find any tutorials that cover it...

    maybe its not in JS???

    help appreciated.

  2. #2
    SitePoint Zealot
    Join Date
    Jul 2002
    Posts
    168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    From http://www.really-fine.com/javascript_if_then_else.html :

    Code:
    var fruit = "apple";
    
    switch (fruit)
    {
      case "apple" : 
         document.writeln("An " + fruit + " is red.");
         break;
      case "bananna" : 
         document.writeln("An " + fruit + " is yellow.");
         break;
      default : 
         document.writeln("What color is your fruit?");
         break;
    }

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2002
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cheers
    Last edited by Lunchy_Munchy; Sep 16, 2002 at 06:24.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •