Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



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

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 22-09-2009
Member
 
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.

Reply With Quote
  #2  
Old 22-09-2009
Member
 
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.
Reply With Quote
  #3  
Old 22-09-2009
Member
 
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.
Reply With Quote
  #4  
Old 22-09-2009
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How do we write exit procedure or function in javascript to exit middle of the program?"
Thread Thread Starter Forum Replies Last Post
StarCraft 2 crashes on exit Reuben 1 Video Games 6 25-03-2011 10:20 PM
how to exit from align screen Koena Portable Devices 4 10-11-2010 06:45 AM
Exit a Silverlight Application KornFlexia Portable Devices 4 26-10-2010 07:43 PM
When I exit from Gomorrah it Crashes Hishem-Remashiya Video Games 5 25-10-2010 09:16 AM
Visual C++ to end a loop & exit from program? RadhaV Software Development 4 21-02-2009 05:58 PM


All times are GMT +5.5. The time now is 02:19 PM.