Forum Moderators: open
I am learning my way around JavaScript. Based on info I found on the web, I set up this script to check the status of a checkbox when it is changed. Can anyone tell me why it's not working? The script is in the <head> and the form is in the <body>. It doesn't seem to be executing at all; even the alert('HELP!') doesn't happen. Doesn't work for onClick either.
Thanks!
Perry
<script language="JavaScript">
<!-- Begin
function checkCheckBox() {
if(document.forms[simple].checkbox[0].checked){
alert('It's checked');
}
else{
alert('Not checked.');
}
alert('HELP!');
// -->
</script>.
.
.<form name=simple>
<input type="checkbox" value="1" name="simpleFormatEnable" onChange="javascript:checkCheckBox();">
.
.
.
</form>
<SCRIPT type="text/javascript">
function checkCheckBox(box)
{
if(box.checked) {
// box is checked
} else {
// box not checked
}
}
</SCRIPT>
<FORM ...>
<INPUT type="checkbox" ... onClick="checkCheckBox(this);">
...
</FORM>