In my HTML, I have several of the following:
<input type='checkbox' name='right[]' id='right[]' value='0' />
All are the same except the value is set differently for each one. The
reason for the [] is so I can access the checkbox values as an array on
the processing page (when clicking 'Submit');
However, I want my Javascript code to examine these objects first. My
onclick event handler function (below) is called (I get the 'hi there'
popup), but it does nothing afterward (i.e., neither 'checkbox' alert
appears, and the handler, strangely, seems to return 'true').
I suppose my problem is that I am not specifying the checkbox array
properly. I tried several variations, but I've been working on this
problem alone for several hours and am getting nowhere. Can someone show
me the correct syntax to do this, please. (My form name and id are set
to 'appl'...)
<script lang='JavaScrip t'>
function verifyAllChecke d()
{
alert('hi there');
if(document.app l.right[0].checked == true) {
alert('checkbox is checked');
} else {
alert('checkbox is not checked');
}
return false;
}
</script>
<input type='checkbox' name='right[]' id='right[]' value='0' />
All are the same except the value is set differently for each one. The
reason for the [] is so I can access the checkbox values as an array on
the processing page (when clicking 'Submit');
However, I want my Javascript code to examine these objects first. My
onclick event handler function (below) is called (I get the 'hi there'
popup), but it does nothing afterward (i.e., neither 'checkbox' alert
appears, and the handler, strangely, seems to return 'true').
I suppose my problem is that I am not specifying the checkbox array
properly. I tried several variations, but I've been working on this
problem alone for several hours and am getting nowhere. Can someone show
me the correct syntax to do this, please. (My form name and id are set
to 'appl'...)
<script lang='JavaScrip t'>
function verifyAllChecke d()
{
alert('hi there');
if(document.app l.right[0].checked == true) {
alert('checkbox is checked');
} else {
alert('checkbox is not checked');
}
return false;
}
</script>
Comment