+ 2
Can you change parts of code with other code
I want to make it that if I press button a function x is called, if I press button b and after that button a again function y is called. But it shouldn't be solved with an if...then...else syntax. Any ideas or is the problem unclear?
6 Respuestas
+ 4
I would create a boolean and set it to true when I press a. Then, if b is pressed and this boolean is true, the other function is executed.
But you will need at least an if statement or as mentioned by @Frank a ternary operator.
+ 2
'Shouldn't be solved with if,then,else syntax'
If this is like a homework assignment you could use a tenary operator as a stand in for if/else statement. Whats the need for this restriction? More detail would be useful.
+ 1
button a calls function x
button b along with button a call function y right?
0
@Drax I thought of that myselfe, I'm just a relative newbee so I thought there would be a better way to solve the problem. But thanks.
- 1
Look at PHP. I don't know of a way in Javascript.
- 1
what I think.. is...since you want a button to call the function...then assign the function to the button...just like you assign a link to an image.. when you click the image.. the link loads.. right???