hi
I am generating a set of dynamic checkboxes via php.
I have to check that the uer should atleast check one checkbox. When
there are more then 1 checkbox my javascript works but if there is
only one check box then my javascript doesnt works. My code is
<script>
function deletecheck()
{
for (i=0;i<document .form.elements['projectChecked[]'].length;i++)
{ if(document.for m.elements['projectChecked[]'][i].checked==true)
{
return true;
}
}
alert ("Please select a project to delete");
return false;
}
</script>
<form ......onsubmit= 'return deletecheck();' >
<?php
foreach(.....)
{
echo "<input type='checkbox' name='projectCh ecked[]'
value='".$proje ctName."' >";
}
?>
I am generating a set of dynamic checkboxes via php.
I have to check that the uer should atleast check one checkbox. When
there are more then 1 checkbox my javascript works but if there is
only one check box then my javascript doesnt works. My code is
<script>
function deletecheck()
{
for (i=0;i<document .form.elements['projectChecked[]'].length;i++)
{ if(document.for m.elements['projectChecked[]'][i].checked==true)
{
return true;
}
}
alert ("Please select a project to delete");
return false;
}
</script>
<form ......onsubmit= 'return deletecheck();' >
<?php
foreach(.....)
{
echo "<input type='checkbox' name='projectCh ecked[]'
value='".$proje ctName."' >";
}
?>
Comment