R
reto
I get an 'undefined' object when trying to get the number of
checkboxes (with same name) in a form and there's only one checkbox.
However when there are two or more, I get the correct number.
<script>
function howmanyckboxes(){
alert(document.myform.mycheckbox.length);
}
</script>
-- HTML----
<form name="myform">
<input type="checkbox" name="mycheckbox" value=1>
<input type="checkbox" name="mycheckbox" value=2>
<input type="checkbox" name="mycheckbox" value=3>
</form>
Any ideas why the array length attribute reports 'undefined' when
there's one checkbox but correctly reports two or more?
Thanks
checkboxes (with same name) in a form and there's only one checkbox.
However when there are two or more, I get the correct number.
<script>
function howmanyckboxes(){
alert(document.myform.mycheckbox.length);
}
</script>
-- HTML----
<form name="myform">
<input type="checkbox" name="mycheckbox" value=1>
<input type="checkbox" name="mycheckbox" value=2>
<input type="checkbox" name="mycheckbox" value=3>
</form>
Any ideas why the array length attribute reports 'undefined' when
there's one checkbox but correctly reports two or more?
Thanks