Hi guys, sorry, I couldnt think of a better name for the title of this post.
I have the following function:
HTML Code:
    var theChecks = document.getElementsByTagName('input');
    var i;
    for(i = 0; i < theChecks.length; i++)
    {    
        if(theChecks[i].type == "checkbox")
        {
            var thisCheck = theChecks[i];
            thisCheck.onclick = function()
            {
                if(thisCheck.checked){
                    alert("checked");
                }
                else
                {
                    alert("unchecked");
                }            
            }                
        }            
    }
What I am ultimately trying to achieve, is run a function when the checkbox is first checked, and then run a different function when the same checkbox is unchecked. At the moment, the "unchecked" alert shows on check AND uncheck.

Could somebody please let me know what I am doing wrong in the code ?

D