0

I have particular function named profilefrm() in which I am checking conditions returning true or false, I have created another function checkcontacts(). I have called this function in first one. I have successfully returning true or false from second one. I have flow is

function profilefrm(){
if condition1{
// on false 
returning false;
}
checkcontacts();
}

function checkcontacts(){
if condition1{
// on false 
returning false;
}
return true;
}

But issue is on false condition in second function it is taken as true in first one. and refreshing page accordingly.

2
  • Can you please provide us with original code ? Commented Oct 25, 2011 at 8:07
  • I think you forgot to return the return value from checkcontracts in profilefrm. You're now just calling the function but not returning it's result from there. Commented Oct 25, 2011 at 8:08

2 Answers 2

1

You could return the result of the checkcontacts function:

function profilefrm() {
    if (condition1) {
        // on false 
        return false;
    }

    return checkcontacts();
}
Sign up to request clarification or add additional context in comments.

6 Comments

But as I am calling function checkcontacts() in middle of function profilefrm() so if checkcontacts() return true it will also return true in mid of function profilefrm()
@RahulSingh, in this case assign the result of the checkcontact to a variable that you could use later when returning: var result = checkcontacts();.
What would happen false or true will be stored in result. what happen on both conditions.?
@RahulSingh, this will depend on what the checkcontacts function returns.
on false condition from second one. it will return false at that moment. but in case if it return true than I need to check rest conditions written in profilefrm() after checkcontacts().
|
0

function's return value should specify. function do no return if not specify.

firtst function change to below.

function profilefrm(){
    if condition1{
        // on false 
        returning false;
    }
    return checkcontacts();
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.