Results 1 to 4 of 4

Thread: How do we write exit procedure or function in javascript to exit middle of the program?

  1. #1
    Join Date
    Nov 2008
    Posts
    89

    How do we write exit procedure or function in javascript to exit middle of the program?

    How do we exit a procedure/function in javascript? I have a form on a web page. When my "Submit" button is pressed, a function is called that validates my form. If a particular radio button is selected, I want to exit the function and forget validating the form. I am very frustrated with this problem since my book, plus all my searches on the web have not shown anybody doing this with javascript.

  2. #2
    Join Date
    Mar 2008
    Posts
    258

    Re: How do we write exit procedure or function in javascript to exit middle of the program?

    "return" lets you exit a function and optionally return a value. Since you have multiple RadioButtons with the same name, document.RequestForm.DBEnhance will return an array. There is no such global function either. In fact, even if you use return, which can be used to prematurely exit functions. And also there is no need to call anything to exit an if statement, it does so automatically once the script within the statement is executed.

  3. #3
    Join Date
    Jan 2009
    Posts
    99

    Re: How do we write exit procedure or function in javascript to exit middle of the program?

    I'm not sure if I agree with you here. I was always under the impression that the break statement can be used to break out of a while, if, switch, or for statement. I hate to suggest this but how about thinking of causing an error to occur in the JavaScript code? That stops execution so that you don't have to loop endlessly and have a potential crash on your hands.

  4. #4
    Join Date
    Oct 2008
    Posts
    77

    Re: How do we write exit procedure or function in javascript to exit middle of the program?

    If the function supplied is the only script then it will automatically cease with the execution with the edit that I supplied, if it is called by another function then all that has to be done is to return false to that call. The code throws up "'exit' is undefined" most likely because 'exit' is undefined in that Javascript. It's not on the list of reserved words for the language, and you haven't defined it anywhere. While the break statement on its own can only be used to exit a loop, the optional label can be added to break to exit any kind of statement.

Similar Threads

  1. StarCraft 2 crashes on exit
    By Reuben 1 in forum Video Games
    Replies: 6
    Last Post: 25-03-2011, 10:20 PM
  2. how to exit from align screen
    By Koena in forum Portable Devices
    Replies: 4
    Last Post: 10-11-2010, 07:45 AM
  3. Exit a Silverlight Application
    By KornFlexia in forum Portable Devices
    Replies: 4
    Last Post: 26-10-2010, 07:43 PM
  4. When I exit from Gomorrah it Crashes
    By Hishem-Remashiya in forum Video Games
    Replies: 5
    Last Post: 25-10-2010, 09:16 AM
  5. Visual C++ to end a loop & exit from program?
    By RadhaV in forum Software Development
    Replies: 4
    Last Post: 21-02-2009, 06:58 PM

Tags for this Thread

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
  •  
Page generated in 1,728,568,764.42139 seconds with 17 queries