I have a table that display some messages and the first row its a checkbox. The name of the checkbox is like “checkbox[]” so , when i get the post data i can delete them all from the database. This is working fine, the problem is that im trying to make a select /unselect all for the checkbox and its not working no mather what i try. Anyone have experiencie with these??
Here is my code:
[CODE]<form name=”formmsg” id=”formmsg” method=”post” action=”” class=”tabladiv”>
<table id=”tablamensajes” class=”tabladiv”><tr><td><div class=”cabezerabox”> </div></td><td style=”width:100px”><div class=”cabezerabox”>Received</div></td><td style=”width:400px”><div class=”cabezerabox”>Mensaje</div></td><td><div class=”cabezerabox”>Sender</td></tr>
<tr><td class=”check”><input type=”checkbox” name=”chkIdMsg[<? echo $i;?>]” value=”<? echo $mensa[$i][‘idMsg’];?>”></td><td class=”mensajes”><? echo $mensa[$i][‘fecha’];?></td><td id=”<? echo $id;?>” class=”filas” onclick=”mostrarOcultar(this)”><a href=”#” onclick=”function(); return false;”><? echo $resumen;?>…</a></td><td class=”mensajes”><a href=”#” onclick=”function(); return false;”><img src=”images/who.png” height=”30px” width=”30px”></img></a></td></tr>
<tr id=”<? echo $id;?>” class=”filasocultas”><td colspan=”4″ class=”mensajeentero”><? echo nl2br($mensa[$i][‘mensaje’]);?></td></tr>
<tr><td colspan=”4″> <img src=”images/arrow.png”></img> <a href=”#” onclick=”marcarTodos()”>Select All /Unselect All</a><a href=”#” onclick=”document.formmsg.submit();”><img src=”images/drop.png”>Delete Selected</img></a></td></tr>
</table></form></div>
And now the function to check all
[CODE]function marcarTodos(){
var objCheckBoxes = document.forms[“formmsg”].elements[“chkIdMsg[]”];
if(!objCheckBoxes){
alert(“no hay”);
return;
}
var countCheckBoxes = objCheckBoxes.length;
for(i=0;i<countCheckBoxes;i++){
objCheckBoxes[i].click();
}
}
Hope someone can help.Thanks