Problem with multiple checkbox
- by Pushpendra
I am using a checkbox that has the name selectedids[], and I am trying to select all checkbox with the JavaScript but the code is not working. However, when I change the name of checkbox to selectedids it works but I can't do so because I need all the ids that are selected on the POSTED page.
The checkbox is as follow.
foreach($rows as $row)
{
<input type="checkbox" name="selectedids[]" value="<?php echo $row['id']; ?>" class="checkbox" />
........
........
}
And the Java-script function is as follow
function SetAllCheckBoxes(CheckValue)
{
var CheckValue=true;
if(!document.forms['main'])
return;
var objCheckBoxes = document.forms['main'].elements['selectedids[]'];
if(!objCheckBoxes)
return;
var countCheckBoxes = objCheckBoxes.length;
if(!countCheckBoxes)
objCheckBoxes.checked = CheckValue;
else
// set the check value for all check boxes
for(var i = 0; i < countCheckBoxes; i++)
objCheckBoxes[i].checked = CheckValue;
}
Please help me.
Thanks in advance..