Page 1 of 1

how to validate array check box in php

Posted: Thu Dec 31, 2009 5:24 am
by manojsemwal1
hai using the following array check box in my php script

<input type ="checkbox" name="sel[]" value="<?php echo $b[TempID]; ?>"></div>
its inside the while loop.



for validation iam using javascript code are as :
var d=document.getElementById('div-id');
var dd=d.getElementsByTagName('input');

for (i=0;i<dd.length;i++)
{
var j=dd;
if ( j.type=='checkbox' )
{
if ( j.checked == true )
{
return true;
break;

}



else ( j.checked == false )
{
alert("Pl Select Student to Move ");
return false;
}

}

}
its working but it asking for select everycheck box while its depends on user how many checkbox he can select.....

Re: how to validate array check box in php

Posted: Thu Dec 31, 2009 3:13 pm
by tr0gd0rr
Not sure what you are asking. Are you needing it to confirm that at least X boxes are checked instead of confirming whether all boxes are checked?

Re: how to validate array check box in php

Posted: Fri Jan 01, 2010 12:03 am
by manojsemwal1
yes i need that........
actually it is a list of student and iam using check box to allocate the student to their related center so we have to need select the student and allocate it in the center.
but for that i used to validate the first user select the center name and then select at least one student.
i used the script but in this script if i select a student again its asking for select student.

thanks

Re: how to validate array check box in php

Posted: Fri Jan 01, 2010 12:35 am
by daedalus__
if you edit your post to use code tags, ill help

Re: how to validate array check box in php

Posted: Fri Jan 01, 2010 1:55 am
by manojsemwal1
Which post do u want to edit..while the code is first post..............on the top