Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/09/2010, 15:52
walrus86
 
Fecha de Ingreso: junio-2010
Mensajes: 155
Antigüedad: 13 años, 11 meses
Puntos: 0
marcar todos los checkbox de un formulario

hola que tal, tengo una pantalla de mensajes, cada uno en una fila de una tabla. en la primera fila tengo un checkbox que si selecciono tiene que checkear automaticamente todos los otros checkbox del formulario.

Hice este codigo recien pero no me esta funcionando, alguien puede decirme donde esta el error???

EL HTML:
Cita:
<form method="post" action="http://localhost/prueba/index.php/tuespacio/decidir_mensajes" name="form">
<table>
<tr>
<td><input type='checkbox' name='todos' onclick="Marcar(document.getElementById('form'));"/></td>
<td>Para</td><td>Asunto</td><td>Fecha</td>
</tr>
<tr>
<td><input type='checkbox' name='mensajes[]' value='1'/></td>
<td>destinatario1</td><td>Asunto1</td><td>Fecha1</td>
</tr>
<tr>
<td><input type='checkbox' name='mensajes[]' value='2'/></td>
<td>destinatario2</td><td>Asunto2</td><td>Fecha2</td>
</tr>
<tr>
<td><input type='checkbox' name='mensajes[]' value='3'/></td>
<td>destinatario2</td><td>Asunto2</td><td>Fecha2</td>
</tr>
<table>
</form>
EL SCRIPT:
Cita:
function Marcar(form) {
if (form.todos.checked == true){
for(var i = 0; i < form["mensajes[]"].length; i++){
form["mensajes[]"][i].checked = true;
}
}
}
gracias por tomarse el tiempo de leer ;)