How to check and uncheck all checkboxes at the same time by pressing a button

-1

I need this function they could help me. From already thank you very much. This is my code:

include('conexion.php');
include('bloquedeseguridad.php');
$query="SELECT identificacion as cedula, id as id , nombre as nombre, telone as telefono, teltwo as daviplata, calificacion as grupo FROM 'vw_usupreaprobados'  ORDER BY 'vw_usupreaprobados'.id ASC";
$datos= null;
$datos = mysql_query($query);
?>
<div class="dropdown">
  <button onclick="myFunction()" class="dropbtn">MENU</button>
  <div id="myDropdown" class="dropdown-content">
    <a href="administrarcreditos.php">Administrar creditos</a>
    <a href="enviarPrimerMensaje.php">Enviar mensaje</a>
  </div>
</div>
<button type="button" id="button"><a href="salir.php">Salir</a></button>
<p style="text-align: center;">Enviar Mensaje</p>
<button type="button" id="button">>Seleccionar todo</button>
<br><br>
<center>
   <hr>
   <?php if ($datos) {   ?>
<table>
 <tr>
  <th>       </th>
  <th>Cédula</th>
  <th>Nombre</th>
  <th>Telefeno</th>
  <th>Telefono Daviplata</th>
   <th>Grupo</th>
  <th></th>
 </tr>
 <?php  while ($registro=mysql_fetch_assoc($datos)) {?>
 <tr>
  <td><?php echo $registro['id'];?></td>
  <td><?php echo $registro['cedula']; ?></td>
  <td><?php echo $registro['nombre']; ?></td>
  <td><?php echo $registro['telefono']; ?></td>
  <td><?php echo $registro['daviplata']; ?></td>
  <td><?php echo $registro['grupo']; ?></td>
  <td>
  <input type="checkbox" onchange="actualizar(this.id)" value="first_checkbox" id="<?php echo $registro['id'] ?>"><br>
</td>
 </tr>
 <?php }?>
</table>
<?php   } else{?>
   <p> No hay información </p>
   <?php } ?>
   <hr>
</center>
<input type="button" id="boton" value="Enviar" onclick="enviarMensaje()">
    
asked by Diego Lopez 15.11.2017 в 15:12
source

1 answer

2

About your concern I leave you a related link:

Html

<input type="checkbox" id="setting-1" class="settings" />
<input type="checkbox" id="setting-2" class="settings" />
<input type="checkbox" id="setting-3" class="settings" />
<input type="checkbox" id="setting-4" class="settings" />
<input type="checkbox" id="setting-5" class="settings" />

<button class="check-all">Check All</button>

JS

var checked = false;

$('.check-all').on('click',function(){

if(checked == false) {
$('.settings').prop('checked', true);
checked = true;
} else {
$('.settings').prop('checked', false);
checked = false;
}

});

By link

What you need to do is manipulate the properties from the jquery of the html, you do it from the DOM, and therefore you need to work with the events of the input, in this particular case with the onclick and generate a group badge to the input that you need to group, for this you can use classes and if you need to iterate later it would be tmb with jquery with .each to obtain the id's of each chexbox. Greetings.

    
answered by 15.11.2017 / 15:20
source