how to validate array check box in php
Posted: Thu Dec 31, 2009 5:24 am
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.....
<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.....