
salvacao
Membros-
Total de itens
9 -
Registro em
-
Última visita
Tudo que salvacao postou
-
Crystian valeu deu certinho. Agora tenho um problema que o textfield do CPF também é do CNPJ, é o mesmo campo. Como posso fazer? você tme este mesmo código do CPF para o CNPJ? Outra coisinha a máscara deu belezinha, só que tenho que tirar a máscara na hora que eu apertar o botão para salvar na tabela. Como posso fazer isso?
-
Crystian, fiz da forma que você falou coloquei todo o código, mas quando estou no campo informando o Cpf e dou TAB ele dá uma mensagem no rodapé do Internet Explorer “Erro na página”. O que devo fazer? <code> <script Language = "JavaScript"> function VerificaCPF(nome) { var CPF = getValue(nome); if (CPF == '') { alert('Favor informar o CPF!'); return false;} CPF = Limp(CPF); total = CPF.length; for(t=0; t < 10; t++){ cont = 0; for(a=0; a < total; a++){ if(CPF.substring(a,a+1)==(t+'')){ cont++; if(cont == 11){alert('CPF inválido.'); return false;} } } } var POSICAO, I, SOMA, DV, DV_INFORMADO; var DIGITO = new Array(10); DV_INFORMADO = CPF.substr(9, 2); for (I=0; I<=8; I++) { DIGITO = CPF.substr( I, 1); } POSICAO = 10; SOMA = 0; for (I=0; I<=8; I++) { SOMA = SOMA + DIGITO * POSICAO; POSICAO = POSICAO - 1; } DIGITO[9] = SOMA % 11; if (DIGITO[9] < 2) { DIGITO[9] = 0; } else{ DIGITO[9] = 11 - DIGITO[9]; } POSICAO = 11; SOMA = 0; for (I=0; I<=9; I++) { SOMA = SOMA + DIGITO * POSICAO; POSICAO = POSICAO - 1; } DIGITO[10] = SOMA % 11; if (DIGITO[10] < 2) { DIGITO[10] = 0; } else { DIGITO[10] = 11 - DIGITO[10]; } DV = DIGITO[9] * 10 + DIGITO[10]; if (DV != DV_INFORMADO) { if(msgCPF == 'no') alert('CPF inválido'); return false; } return true; } function FormataCPF(nome){ CPF = getValue(nome); CPF = Limp(CPF); if(CPF.length == 11){ value = Mascara(CPF, '999.999.999-99'); setValue(nome, value); msgCPF = 'no'; } else { if(CPF.length > 0){ erroValue = ('Verifique o CPF digitado, pois estão faltando ou sobrando números.'); msgCPF = 'yes'; } else msgCPF = 'no'; } } function Limp©{ qtd = c.length; var v = ''; for (i=0; i < qtd; i++) for(t=0; t < 10; t++){ if(c.substring(i,i+1) == t && c.substring(i,i+1) != " ") v += c.substring(i,i+1);} return(v); } function getValue(nome){ var obj = eval("document.forms[0]."+nome+".value"); return obj; } function setValue(nome, valor){ obj = eval("document.forms[0]."+nome); obj.value = valor; } </script> </head> <form action="<?php echo $editFormAction; ?>" method="POST" name="frmincfornecedor" id="frmincfornecedor"> <td width="40%"><input name="frmCnpjCpf" type="text" id="frmCnpjCpf" size="25" maxlength="25" onChange="VerificaCPF(this.frmincfornecedor,'frmCnpjCpf','frmCnpjCpf')"></td> </code>
-
Galera peguei alguns códigos referente a máscara no fórum só que não está dando certo, será que podem me ajudar? Coloquei o meu código aí para vocês entenderem o que fiz. Quando eu digito o cpf no ‘text’ nada acontece. <script language=javascript> function FormataCPF(nome){ CPF = getValue(nome); CPF = Limp(CPF); if(CPF.length == 11){ value = Mascara(CPF, '999.999.999-99'); setValue(nome, value); msgCPF = 'no'; } else { if(CPF.length > 0){ erroValue = ('Verifique o CPF digitado, pois estão faltando ou sobrando números.'); msgCPF = 'yes'; } else msgCPF = 'no'; } } </script> <form action="<?php echo $editFormAction; ?>" method="POST" name="frmincfornecedor" id="frmincfornecedor"> . . <td width="40%"><input name="frmCnpjCpf" type="text" id="frmCnpjCpf" size="25" maxlength="25" onChange="FormataCPF(this.frmincfornecedor,'frmCnpjCpf','frmCnpjCpf')"></td> </form>
-
Estou tentando colocar uma mensagem num formulário de inserção, caso o CPF/CNPJ (que é um campo único na tabela e é a chave primária) exista ele emita uma mensagem que não é possível inserir. Coloquei uma verificação antes do inserte mas parece que ele não está fazendo. Vou colocar o meu código aí, para facilitar o entendimento: if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmincfornecedor")) { $resultado=$_POST['frmCnpjCpf']; if ($row_Fornecedor['CpfCnpj'] != $resultado) { $insertSQL = sprintf("INSERT INTO fornecedor (CpfCnpj, Nome, Endereco, Bairro, Cidade, Cep, Telefone, Celular, Fax, Email, Site, Uf, Contato) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['frmCnpjCpf'], "text"), GetSQLValueString($_POST['frmNome'], "text"), GetSQLValueString($_POST['frmEndereco'], "text"), GetSQLValueString($_POST['frmBairro'], "text"), GetSQLValueString($_POST['frmCidade'], "text"), GetSQLValueString($_POST['frmCep'], "int"), GetSQLValueString($_POST['frmTelefone'], "int"), GetSQLValueString($_POST['frmCelular'], "int"), GetSQLValueString($_POST['frmFax'], "int"), GetSQLValueString($_POST['frmEmail'], "text"), GetSQLValueString($_POST['frmSite'], "text"), GetSQLValueString($_POST['frmUf'], "int"), GetSQLValueString($_POST['frmContato'], "text")); mysql_select_db($database_gvshopping, $gvshopping); $Result1 = mysql_query($insertSQL, $gvshopping) or die(mysql_error()); $insertGoTo = "/cadfornecedor.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } else { ?> <script> alert("Cpf ou Cnpj já existe!"); location.href = "cadfornecedor.php"; </script> <?php } } ?>
-
Tenho uma tela com os seguintes campos: Telefone, Cep, Data A minha dúvida é a seguinte como coloco máscara nestes campos? Por exemplo o telefone- (00)0000-0000
-
Estou precisando emitir uma mensagem na tela igual aquelas janelas pop-up, que tem a mensagem e o botão OK. Qual o comando em PHp que consigo uma janela assim de mensagem que na hora que eu apertar o OK ele direciona para uma determinada tela?
-
O meu problema é o seguinte estou tentando excluir um registro quando eu aperto o botão “Excluir” ele não está excluindo, ele simplesmente volta na tela anterior,parece que ele não está entrando na função de exclusão. Eu tenho que informar alguma coisa no form para ele executar a função de exclusão que está vindo no início do arquivo no momento que eu apertar o botão? Segue o código para melhor exemplificar a minha dúvida. <?php require_once('Connections/gvshopping.php'); ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } if ((isset($_GET['codProduto'])) && ($_GET['codProduto'] != "")) { $deleteSQL = sprintf("DELETE FROM produto WHERE codProduto=%s", GetSQLValueString($_GET['codProduto'], "int")); mysql_select_db($database_gvshopping, $gvshopping); $Result1 = mysql_query($deleteSQL, $gvshopping) or die(mysql_error()); $deleteGoTo = "/index.php"; if (isset($_SERVER['QUERY_STRING'])) { $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?"; $deleteGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $deleteGoTo)); } ?> <form action="" method="post" name="frmExProduto" id="frmExProduto"> . . . <input name="Excluir" type="submit" class="Botao" id="Excluir" value="Excluir Produto"> </form>
-
Estou utilizando o procedimento dentro do Dreamweaver (Application->Server Behaviors ->Delete Record) . O meu problema é o seguinte estou tentando excluir um registro quando eu aperto o botão “Excluir” ele não está excluindo, ele simplesmente volta na tela anterior,parece que ele não está entrando na função de exclusão. Eu tenho que informar alguma coisa no form para ele executar a função de exclusão que está vindo no início do arquivo no momento que eu apertar o botão? Segue o código para melhor exemplificar a minha dúvida: <?php require_once('Connections/gvshopping.php'); ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } if ((isset($_GET['codProduto'])) && ($_GET['codProduto'] != "")) { $deleteSQL = sprintf("DELETE FROM produto WHERE codProduto=%s", GetSQLValueString($_GET['codProduto'], "int")); mysql_select_db($database_gvshopping, $gvshopping); $Result1 = mysql_query($deleteSQL, $gvshopping) or die(mysql_error()); $deleteGoTo = "/index.php"; if (isset($_SERVER['QUERY_STRING'])) { $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?"; $deleteGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $deleteGoTo)); } ?> <form action="" method="post" name="frmExProduto" id="frmExProduto"> . . <input name="Excluir" type="submit" class="Botao" id="Excluir" value="Excluir Produto"> </form>
-
Eu tenho um list/menu na minha tela que lista as Unidade. Tenho uma tela de alteração, onde escolho um registro ele coloca todas as informações nesta tela como nome, cidade... Aí que vem minha dúvida como faço ele posicionar neste list/menu na Unidade que este registro que estou buscando tem, e quando clicar na seta ele abri o list/menu com as outras opções caso eu queira alterar a unidade? O meu código está da seguinte forma: <td width="12%"><select name="frmAltUnidade" id="frmAltUnidade"> <?php do { ?> <option value="<?php echo $row_Unidade['codUnidade']?>" selected><?php echo $row_Unidade['Abreviatura']?></option> <?php } while ($row_Unidade = mysql_fetch_assoc($Unidade)); $rows = mysql_num_rows($Unidade); if($rows > 0) { mysql_data_seek($Unidade, 0); $row_Unidade = mysql_fetch_assoc($Unidade); }?> </select></td> Onde neste código que coloco para ele posicionar na Unidade que meu registro da tabela está trazendo?