Ver Mensaje Individual
  #4 (permalink)  
Antiguo 08/06/2012, 17:21
caitoss
 
Fecha de Ingreso: noviembre-2003
Mensajes: 78
Antigüedad: 20 años, 5 meses
Puntos: 0
Respuesta: Checkbox por grupos en tabla dinámica

Cita:
Iniciado por diamari Ver Mensaje
No visualizo que quieres hacer, ni el problema y el código no me ayuda mucho ya que no lo puedo ejecutar. Pero vamos a intentar.
A continuación indico, de manera simple, en código htlm, el resultado que pretendo ontener teniendo el cuenta que la tabla es dinámica por lo que los módulos y las divisiones o proyectos son variables que obtengo de sus respectivas bases de datos.
Lo que me interesa es poder hacer funcionar los CheckAll de cada módulo ademas de dejar operativo el CheckAll principal que selecciona todo.
El script que presento no funciona ningún CheckAll pero si quitas los CheckAll de los módulos (marcado en color) funciona el principal lo que quiere decir que es un fallo de identificación del array en la función CheckAll() y esto es lo que debo conseguir.
Muchas gracias por tu atención

<html>
<form method="post" name="peruid">
<table border="1" bordercolor ="e5cd78" width="80%" cellpadding="0" cellspacing="0">
<tr>
<td width="20%">TODOS<br><input name="allbox" onclick="CheckAll();" type="checkbox" value=""._CHECKALL.""></td>
<td width="20%" colspan="4" align="center">PERMISOS DE GESTION A USUARIO XXXXX</td>
</tr>
<!--------------------
<tr>
<td width="20%">DIVISIONES O PROYECTOS($bd)<br></td>
<td width="20%" align="center">Module($modid1)<br>DOC<br><input name="allbox" onclick="CheckAll();" type="checkbox" value=""._CHECKALL.""></td>
<td width="20%" align="center">Module($modid2)<br>GCMA<br><input name="allbox" onclick="CheckAll();" type="checkbox" value=""._CHECKALL."" ></td>
<td width="20%" align="center">Module($modid3)<br>PROY<br><input name="allbox" onclick="CheckAll();" type="checkbox" value=""._CHECKALL."" ></td>
<td width="20%" align="center">Module($modid4)<br>SCRM<br><input name="allbox" onclick="CheckAll();" type="checkbox" value=""._CHECKALL."" ></td>
</tr>
-------------------------->
<tr>
<td width="20%">$bd1 PROYECTO1</td>
<td width="20%" align="center"><input type="checkbox" name="a_permiso[]" value="$modid1$bd1"></td>
<td width="20%" align="center"><input type="checkbox" name="a_permiso[]" value="$modid1$bd2"></td>
<td width="20%" align="center"><input type="checkbox" name="a_permiso[]" value="$modid1$bd3"></td>
<td width="20%" align="center"><input type="checkbox" name="a_permiso[]" value="$modid1$bd4"></td>
</tr>
<tr>
<td width="20%">$bd2 PROYECTO 2</td>
<td width="20%" align="center"><input type="checkbox" name="a_permiso[]" value="$modid2$bd1"></td>
<td width="20%" align="center"><input type="checkbox" name="a_permiso[]" value="$modid2$bd2"></td>
<td width="20%" align="center"><input type="checkbox" name="a_permiso[]" value="$modid2$bd3"></td>
<td width="20%" align="center"><input type="checkbox" name="a_permiso[]" value="$modid2$bd4"></td>
</tr>
<tr>
<td width="20%">$bd3 DIVISION 3</td>
<td width="20%" align="center"><input type="checkbox" name="a_permiso[]" value="$modid3$bd1"></td>
<td width="20%" align="center"><input type="checkbox" name="a_permiso[]" value="$modid3$bd1"></td>
<td width="20%" align="center"><input type="checkbox" name="a_permiso[]" value="$modid3$bd3"></td>
<td width="20%" align="center"><input type="checkbox" name="a_permiso[]" value="$modid3$bd4"></td>
</tr>
<tr>
<td width="20%">$bd4 DIVISION 4</td>
<td width="20%" align="center"><input type="checkbox" name="a_permiso[]" value="$modid4$bd1"></td>
<td width="20%" align="center"><input type="checkbox" name="a_permiso[]" value="$modid4$bd2"></td>
<td width="20%" align="center"><input type="checkbox" name="a_permiso[]" value="$modid4$bd3"></td>
<td width="20%" align="center"><input type="checkbox" name="a_permiso[]" value="$modid4$bd4"></td>
</tr>
</table>
</html>
</form>



<?php
echo "<script type='text/javascript'>\n\n
<!--\n\n
function CheckAll() {
for (var i=0;i<document.peruid['a_permiso[]'].length;i++)
document.peruid['a_permiso[]'][i].checked = document.peruid.allbox.checked;
}
function CheckCheckAll() {\n
var TotalBoxes = 0;\n
var TotalOn = 0;\n
for (var i=0;i<document.peruid.elements.length;i++) {\n
var e = document.peruid.elements[i];\n
if ((e.name != 'allbox') && (e.type=='checkbox')) {\n
TotalBoxes++;\n
if (e.checked) {\n
TotalOn++;\n
}\n
}\n
}\n
if (TotalBoxes==TotalOn) {\n
document.peruid.allbox.checked=true;\n
} else {\n
document.peruid.allbox.checked=false;\n
}\n
}\n\n
-->\n
</script>";


?>