Ahora puedes elegir el formulario en el que se aplique, teniendo en cuenta que debes empezar por el cero. El formulario primero es el cero, el segundo es el uno...
Te pongo un ejemplo con el script como sería: Código PHP:
<html>
<head>
<title>Untitled</title>
<script>
function marcar(esto,formulario){
esto=(esto)?true:false;
if(!isNaN(formulario)){
inicio=formulario;
fin=formulario+1;
}
else{inicio=0;
fin=document.forms.length;
}
for(aa=inicio;aa<fin;aa++){
for (a=0;a<document.forms[aa].elements.length;a++){
elemento=document.forms[aa].elements[a]
if(elemento.type="checkbox"){
elemento.checked=esto;
}
}
}
}
</script>
</head>
<body>
Formulario 1
<form action='javascript:alert("enviando!!")' name='pepote' id='pepote'>
<input type="checkbox" name="este" value="1">Este es uno<br>
<input type="checkbox" name="este2" value="2">Este es dos<br>
<input type="checkbox" name="este3" value="3">Este es tres<br>
<input type="checkbox" name="este4" value="4">Este es cuatro<br>
</form>
Formulario 2
<form action='javascript:alert("enviando!!")' name='pepo4te' id='pepo4te'>
<input type="checkbox" name="este" value="1">Este es uno<br>
<input type="checkbox" name="este2" value="2">Este es dos<br>
<input type="checkbox" name="este3" value="3">Este es tres<br>
<input type="checkbox" name="este4" value="4">Este es cuatro<br>
</form>
<a href="javascript:marcar(true)">Marcar todos</a><br>
<a href="javascript:marcar()">Desmarcar todos</a>
<a href="javascript:marcar(true,0)">Marcar todos los del Formulario 1</a><br>
<a href="javascript:marcar('',0)">Desmarcar todos los del Formulario 1</a><br>
<a href="javascript:marcar(true,1)">Marcar todos los del Formulario 2</a><br>
<a href="javascript:marcar('',1)">Desmarcar todos los del Formulario 2</a><br>
</body>
</html>