Ir para conteúdo
Fórum Script Brasil

NOVELLO

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Tudo que NOVELLO postou

  1. COMO FAÇO PARA USAR document.lstSetor.submit(); CORRETAMENTE, POIS ELE NÃO ESTÁ ENVIANDO COM O SEU name="alterar" correto, pois na outra página tenho um switch case que verifica qual botão foi clicado, más ao invés de executar a função alterar como fazia antes de eu usar JS, ele executa a função nula DEFAULT: no caso. Desde já agradeço a quem entender o que eu preciso.obrigado. segue o código que está sendo usado. <HTML> <HEAD> <TITLE>Cadastro de Setor</TITLE> <link rel="stylesheet" href="style02.css" type="text/css" media="all"> <script> function selecionar_tudo(){ for (i=0;i<document.lstSetor.elements.length;i++) if(document.lstSetor.elements[i].type == 'checkbox') document.lstSetor.elements[i].checked=1 } function deselecionar_tudo(){ for (i=0;i<document.lstSetor.elements.length;i++) if(document.lstSetor.elements[i].type == 'checkbox') document.lstSetor.elements[i].checked=0 } function validaCheckBox(){ var elements = document.forms[0].elements; var count=0; for(var i=0; i<elements.length; i++ ){ if( elements[i].type.toLowerCase() == 'checkbox' ){ if( elements[i].checked ) ++count; if(count==2) break; } } if(count==0) { alert("Você deve selecionar ao menos um setor!"); } else if(count>=2) { alert("Você pode alterar um setor por vez!"); } else if(count>=1) { document.lstSetor.submit(); } } </script> </HEAD> <BODY> <div id="container"> <?php //Chamar a conexao include "conexao.php"; //query SQL $strSQL = "SELECT * FROM setor"; // Executa a query (o recordset $rs contém o resultado da query) $rs = mysql_query($strSQL); // Loop pelo recordset $rs - Cada linha vai para um array ($row) usando mysql_fetch_array ?> <form name="lstSetor" method="POST" action="man_setor.php"> <table> <tr> <th colspan="3" align="center"><input type="submit" name="incluir" value="Incluir Novo Setor" />Manutenção de Setores</th> </tr> <tr> <td><input type="checkbox" onclick="java script:selecionar_tudo()" onclick="java script:deselecionar_tudo()" ></td> <td><input type="checkbox" onclick="java script:deselecionar_tudo()" ></td> <td> <input type="button" name="alterar" id="alterar" onclick="java script:validaCheckBox();" value="alterar"> <input type="submit" name="excluir" value="Excluir"/> </td> </tr> <?php // Executar arrayList em setores while($row = mysql_fetch_array($rs)) { echo "<tr> <td><input type='checkbox' id='check' name='codsetor[]' value='" . $row['cod_setor'] . "'></td> <td>" . $row['cod_setor'] . " </td> <td>" . $row['descricao'] . "</td> </tr>"; } // Encerra a conexão mysql_close(); ?> </table> </form> </div> </BODY> </HTML>
×
×
  • Criar Novo...