Event handling in JavaScript using functions with arguments. Is it possible?
I got one problem building my website: I have two buttons, "right" and "left", and I want to call the function turn() using the onClick event handler. The function turn() has one argument: dir, which is either "right" or "left", depending on which button was pressed. I call the function like this: <a href="#" onclick="turn("left")"> <--! I use links as buttons as you see --> For some reason this solution doesn't work for me. I tried it othervise before: I used two different functions, right() and left() for the two possible input "right" and "left". These functions has NO arguments, and the code works perfectly with them... It is possible, that I made a mistake somwhere else in the code, but I need an answer for this problem before I keep searching for bugs. Thanks in advance for the answers!