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.form.elements['projectChecked[]'].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='projectChecked[]' value='".$projectName."' >";
}
?>