php - Problem selecting multiple checkboxes -
i using checkbox has name "selectedids[]" , trying select checkboxes javascript. code not working. when change name of checkbox "selectedids" works, can't because need ids selected on posted page.
the checkbox follows:
foreach($rows $row) { <input type="checkbox" name="selectedids[]" value="<?php echo $row['id']; ?>" class="checkbox" /> ........ ........ }
and java-script function follows:
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 check value check boxes for(var = 0; < countcheckboxes; i++) objcheckboxes[i].checked = checkvalue; }
please me......
thanks in advance.......
do have option use jquery? if so, like:
$(':checkbox').each(function(){ $(this).attr('checked',true); });
it might work try:
$(':checkbox').attr('checked',true);
or, if want make sure boxes checked when page first loads have php creates checkboxes include "checked". i.e.
<input type='checkbox' name='selectedids[]' value='value' checked>
updated use :checkbox per comment
Comments
Post a Comment