0

I have something like this :

div style='cursor: pointer;' onClick='myFunction(" . $_SESSION['pseudos'][$key] . ")'

that is supposed to enable users input while the game (in js) is playing. The user is supposed to clic on 1 out of X how those div to chose which char to kill. However the js doesn't stop and wait for an input. Any idea ?

My function js looks like this :

function myFunction(foo) {
    if (foo === null){
    document.getElementById("button").addEventListener("click", function() {
        foo = myFunction();
    }
    return foo;
}
Patrick Roberts
  • 49,224
  • 10
  • 102
  • 153
Jaune
  • 343
  • 1
  • 8

1 Answers1

-1
foo = myFunction();

is invoking myFunction immediately. So, unless myFunction returns another function that you want your button hooked up to, the line should be:

foo = myFunction;
Scott Marcus
  • 64,069
  • 6
  • 49
  • 71