Ver Mensaje Individual
  #5 (permalink)  
Antiguo 12/05/2009, 10:46
matak
 
Fecha de Ingreso: julio-2008
Ubicación: Alcañiz-Teruel-España
Mensajes: 182
Antigüedad: 15 años, 10 meses
Puntos: 5
Respuesta: Marcar varios checkbox al dar clic

Prueba esto a ver si es lo que buscas

Código html:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  4.  
  5. <meta http-equiv="Content-Language" content="es">
  6. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  7. <SCRIPT LANGUAGE="JavaScript">
  8. function checkAllOrAny(nckecks) {
  9.   for (i=1;i<=nckecks;i++){
  10.    document.getElementById('check_'+i).checked=document.getElementById('all').checked
  11.  }
  12.  if (document.getElementById('all').checked) {
  13.    document.getElementById('opcion').innerHTML='Ninguno'
  14.  }else{
  15.    document.getElementById('opcion').innerHTML='Todos'
  16. }
  17. }
  18. </head>
  19. <tr>
  20. <td>
  21. <input type='checkbox' id="all" onclick="checkAllOrAny(10)"/>
  22. </td>
  23. <td>
  24. <span id="opcion">Todos<span>
  25. </td>
  26. </tr>
  27. <?PHP
  28. for ($i=1;$i<=10;$i++){
  29. ?>
  30. <td>
  31. <input type='checkbox' id="check_<?PHP echo $i; ?>" name="check_<?PHP echo $i; ?>"/>
  32. </td>
  33. <td>
  34. Descriptcion del check<?PHP echo $i; ?>
  35. </td>
  36. </tr>
  37. <?PHP
  38. }
  39. ?>
  40. </body>
  41. </html>

Si generas el los checks dinámicamente en función del número de registros que te devuelve una consulta a una bd tendás que cambiar un poco la parte de PHP que genera el bucle pero no creo que tengas complicación.

Cualquier cosa ya sabes,

Saludos
__________________
Si quieres puedes y si puedes debes. Imposible is nothing!!!