Hi, All
I have a form which contains an array checkboxes. Examples:
<form method ="post" name="form1" id="form1">
<input type="checkbox" name="object[]" id="object[]" value="1">
<input type="checkbox" name="object[]" id="object[]" value="2">
</form>
I using PHP get value of array checkboxes. However, I want to check data of array checkboxes
by javascript. Example:
<script language="jscript">
function CheckData() {
var Form1 = document.forms['form1'].object
var ok = 0
for (i=0;i<Form1.object.length;i++)
{
if (Form1.object.checked) ok = 1
return true
}
if ( ok==0) {
alert("Data invalid")
return false
}
}
</script>
Javascript desn't understand the [] at the end of the name's checkbox.
Javascript errors "object.length is null or not an object". Unfortunately I need the [] there as they are to be processed by some php when I submit the form.
Thanks for all your help