If you debug your code using developer tools, you will notice that this
refers to the window object and not the input control. Consider using the passed in id to retrieve the input and check for checked
value.
function doalert(id){
if(document.getElementById(id).checked) {
alert('checked');
}else{
alert('unchecked');
}
}