php - Keeping checkbox state consistent over multiple checkboxes -


i need check or uncheck automatically 2 hidden checkboxes when main visible 1 checked. 3 checkboxes inside while cycle.

let me explain myself, form:

<form action="updateauc.php" method="post" name="edit">     <div class="editbutton">          <ul>              <li class="leditcnt"><input class="submitbutton" type="submit" name="edit" value="aggiorna trasferimenti" /></li>              <li class="lremove"><a href="auctionfree_list.php"><input name="button"  type="button" class="linkbutton" value="annulla" /></a></li>          </ul>     </div>                     <table width = "100%">         <tr class="title">             <td class="head">player</td>             <td class="head">action</td>             <td class="head">win</td>          </tr>                               <?php { ?>             <tr>             <td class="table1"><?php echo $row_dataauc['playername']; ?></td>             <td class="table1"><?php echo $row_dataauc['amount']; ?> - <?php echo $row_dataauc['teambid']; ?></td>             <td class="table1">                 <input name="enable[]" class="inputfield" type="checkbox" value="<?php echo $row_dataauc['aucid']?>"/>                 <input name="enable2[]" class="inputfield" style="display:none" type="checkbox" value="<?php echo $row_dataauc['id']?>"/>                 <input name="enable3[]" class="inputfield" style="display:none" type="checkbox" value="<?php echo $row_dataauc['coachid']?>"/>             </td>         </tr>         <?php } while ($row_dataauc = mysqli_fetch_assoc($dataauc)); ?>     </table> </form> 

name=”enable[]” main one; when check one, name=”enable2[]” , name”enable3[]”must automatically checked, too.

first of all, think checkboxes should have same name enable[]

onclick function visible checkbox;

onclick="setcb(this)" 

javascript;

first of all, think checkboxes should have same name enable[]

function setcb(element) {   var status = element.checked ? true : false;   var elements = document.getelementbyid("enable");    for( i=0; i<elements.length ; i++ ) {     elements[i].checked = status;   } } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -