Results 1 to 5 of 5

Thread: Can you use a "switch" statement inside a Function

  1. #1
    Join Date
    Dec 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Can you use a "switch" statement inside a Function

    Is it possible to do the following or is my syntax wrong?

    Code:
    function stopbill(btncode){
    switch(btncode)
    case "dlp":
    window.alert("Stop")
    case "dlb":
    window.alert("Back")
    case "dlf":
    window.alert("Next")
    }

    Here is the HTML code where I call the function.

    Code:
    <div align="right">
         <a href="#" id="dlb" onclick="return stopbill('dlb')">
              <img src="images/bctrl.gif" alt="Previous" border="0" id="dlbi"/>
         </a>
    </div>
    Thanks!
    Jodman
    Last edited by Jodman; 12-16-2005 at 04:36 PM.

  2. #2
    Join Date
    Dec 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I found my error. Please remove this post.

    Thanks!
    Jodman

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Yes, you missed the braces. You also forgot to "break;" after your code in each case, which you're no doubt going to ask about in a minute.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Dec 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Nope. Did not need to ask, hence the reason I wanted the post deleted. Thanks for the kind response though.

    Jodman

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    A post shouldn't be deleted if someone can learn from it. If you solve a problem, you ought to say how you solved it, in case someone else has the same.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •