Results 1 to 2 of 2

Thread: How to execute the fuction if the condition is true

  1. #1
    Join Date
    Apr 2012

    How to execute the fuction if the condition is true


    I have a set a condition before executing a js function.The condition is if any alert come by clicking that button at that time the function should not called otherwise it should execute.

    Please suggest me how to do this one.

  2. #2
    Join Date
    Mar 2009
    If I understand what you are trying to say:

    1. set a flag having scope that the function that you don't want to execute can access

    2. Have that function first check the value of the flag at the beginning and have it return immediately without it executing the rest of the code.

    For example:

    var flag = false;

    function showAlert(){
    flag = true;
    alert("Here's an alert");

    function doIfNoAlert(){
    if(flag === true){
    //whatever you otherwise want it to do here
    Last edited by Tcobb; 04-27-2012 at 11:29 AM. Reason: Message fired before I was through

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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