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

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -