wrote on 08 apr 2006 in comp.lang.javascript:
Having some problems with this, check it:
Please quote what you are replying to. If you want to post a followup via
groups.google.com, don't use the "Reply" link at the bottom of the
article. Click on "show options" at the top of the article, then click on
the "Reply" at the bottom of the article headers.
<script>
var booly = true; //(not in a function)
function openinput(){//**(Call this from the button)
if (booly){
null;
}else{
alert('hi2');
}
booly != booly; // **changes booly from true to false or
vice-versa
}//*end of function
</script>
<a href="#" onclick=openinput()>Click</a>
this should in theory show "hi2" after clicking the link twice?
No, because
1 you reload the page every time.
2 != is a comparison operator, not an assignment operator
Try:
<script type='text/javascript'>
var booly = false;
function myTest(){
if (booly)
alert('hi2');
booly = !booly;
return false;
}
</script>
<a href="#" onclick='return myTest()'>Click</a>