On one hand you are passing check
as a parameter in checkbox(check)
function for event onload
and again defining the check
on this line:
var check = document.getElementById("cbxAuth"); //<- error from this line
In addition, why don't you specify some different meaningful function names for events onload
and onchange
.
ADDED, after the question edit with markup, the cbxAuth
is a Server Control so you need to get its ClientID for getting its reference in JavaScript. This way:
var chkbox = document.getElementById("<%= cbxAuth.ClientID %>");
For the other part simple change the function names to some meaningful names as explained earlier.
window.onload = function OnWindowLoad(check) {
var chkbox = document.getElementById("<%= cbxAuth.ClientID %>");
if (chkbox)
{
chkbox.onchange = function OnCheckBoxChange(chkbox) {
// ... rest of your code
};
}
};