1

I have a Javascript function as below:

function letMeGo(var1, var2, var3){
    if(var1 == 1 && var2 == 1 && var3 == 1){
        document.getElementById('goOn').href="goOn.php";
    }
}

the variables are the return of other functions.

And I need it to be triggered by:

<a id="goOn" onclick="letMeGo(var1, var2, var3)">Go On</a> 

it is not working unless I removed the variable in both, the link and the function. How can i get it to work with them?

3
  • If the variables are the return of other functions, why not just call the other functions in letMeGo? Commented Jan 30, 2013 at 21:35
  • 3
    not working means what? Did it catch on fire? What is the error message? What is the mystery var1, var2, var3? Commented Jan 30, 2013 at 21:35
  • 1
    Does this work? <a id="goOn" onclick="letMeGo(1, 1, 1)">Go On</a> . If so, then you need to check the values of those three variables before binding that onClick handler. That code seems to be absent from your question. Commented Jan 30, 2013 at 21:36

1 Answer 1

1

you have to affect the return of the other functions to global variables (example: window.myvar1) and use them instead of your parameters var1, var2, var3.

I mean to not use any parameters in your function letMeGo and inside it, replace var1 by its global variable equivalent, and so on for var2 and var3.

Sign up to request clarification or add additional context in comments.

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.