Ir para conteúdo
Fórum Script Brasil
  • 0

Selecionar Todas Checkbox


sexfashion

Pergunta

1 resposta a esta questão

Posts Recomendados

  • 0

Oh cara... tenho um script aqui pra você...

<html>
<head>
<title>Seleciona todas</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="selecao" method="post" action="">
  <p> 
    <input name="op1" type="checkbox" id="op1" value="">
    Op&ccedil;&atilde;o 1 <br>
    <input name="op2" type="checkbox" id="op2" value="">
    Op&ccedil;&atilde;o 2<br>
    <input name="op3" type="checkbox" id="op3" value="">
    Op&ccedil;&atilde;o 3<br>
    <input name="op4" type="checkbox" id="op4" value="">
    Op&ccedil;&atilde;o 4<br>
    <input name="op5" type="checkbox" id="op5" value="">
    Op&ccedil;&atilde;o 5<br>
    <input name="op6" type="checkbox" id="op6" value="">
    Op&ccedil;&atilde;o 6 </p>
  <p>Selecionar Todas 
    <input name="todas" type="checkbox" id="todas" value="checkbox" onClick="selecionar_todas(this.checked)">
  </p>
</form>
<script language="JavaScript">
formulario=document.selecao;
function selecionar_todas(retorno){
if(retorno==true){
	for(i=0;i<formulario.length;i++){
  if(formulario.elements[i].type=="checkbox" && formulario.elements[i].name!="todas"){
  	if(formulario.elements[i].checked==false){
    formulario.elements[i].checked=true;
  	}
  }
	}
} else {
	for(i=0;i<formulario.length;i++){
  if(formulario.elements[i].type=="checkbox" && formulario.elements[i].name!="todas"){
  	if(formulario.elements[i].checked==true){
    formulario.elements[i].checked=false;
  	}
  }
	}
}
}
</script>
</body>
</html>

Qualquer dúvida posta ae... falowS! ph34r.gif

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...