Forum Moderators: open
Right now I have two functions that run if a variable is clicked.
var1.onclick=function(){...}
var2.onclick=function(){...}
What I'm trying to do is create a senario where if var1 is clicked, one thing happens. If var2 is clicked, another thing happens. And, if there is a click, put not on var1 or var2, something else happens.
I tried adding another line, which works if var1 or var2 is clicked, but two functions run if one of the variables is clicked:
var1.onclick=function(){...}
var2.onclick=function(){...}
document.onclick=function(){...}
What I'm trying to do is run an if/else statement, but I'm not having any luck.
if(var1.onclick==true){...}
elseif(var2.onclick==true){...}
else{...}
What's the right approach to if/else statements when dealing with onclicks, or other classifiers?
Thanks
I'm finding that even with the return false, two things events can be triggered.
var1.onclick=function(){alert("A");return false;}
var2.onclick=function(){alert("B");return false;}
document.onclick=function(){alert("Click");return false;}
If I click on var1, then it alerts "A" followed by "Click".
Do I have something setup wrong? Is it because the return false is inside the function brackets, so it stop running that one function, but continues with the rest of the script?
Anybody have any ideas?
Thanks
var1.onclick=function(){defaultStatus="A";return false;}
var2.onclick=function(){defaultStatus="B";return false;}
document.onclick=function(){defaultStatus="Click";return false;}
and observe status display.