Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    91
    Thanks
    4
    Thanked 9 Times in 9 Posts

    Killing a function

    Hi, im wondering if theres a way to kill a function from executing any further without having to implement an if statement?

    It is part of an ajax project, but its just a basic javascript function. Any ideas?
    Last edited by scoop_987; 08-18-2008 at 10:03 PM.
    Current Project: Nothing at the minute

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,158
    Thanks
    203
    Thanked 2,548 Times in 2,526 Posts
    Without an if statement (or eqivalent) how will you know whether or not to kill the function?

  • #3
    New Coder
    Join Date
    Jul 2008
    Posts
    91
    Thanks
    4
    Thanked 9 Times in 9 Posts
    by sending a variable effectively as a bool. So if its true, kill the function.
    Current Project: Nothing at the minute

  • #4
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    You still have to check it, no?

    return statement will stop execution in the function.

  • Users who have thanked Brandoe85 for this post:

    scoop_987 (08-18-2008)

  • #5
    New Coder
    Join Date
    Jul 2008
    Posts
    91
    Thanks
    4
    Thanked 9 Times in 9 Posts
    Im trying to make an ajax near instant messenger for someone, so im needing to check the posts incase they are blank. But ive set it so the user can either press enter or press a button. The key press is great apart from one pain in the *** of a bug, and the button isnt. With the keypress it is checked in a seperate function (i know, long way for a shortcut) and is then passed to the function that does the ajax calls along with a bool variable which tells if whether or not it is the button that was pressed. If it was the button then do checks, otherwise, dont.

    Ive got it working with an added if else statement, but isnt exactly practical. nor space friendly (i know only about 30 bytes).

    But that "function" return will be perfect. Thanks

    Btw, im new to javascript!
    Current Project: Nothing at the minute


  •  

    Posting Permissions

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