Ir para conteúdo
Fórum Script Brasil

Paiva Jr

Membros
  • Total de itens

    22
  • Registro em

  • Última visita

Sobre Paiva Jr

Paiva Jr's Achievements

0

Reputação

  1. obs.: se colocar o desvio (foco) para um campo após o campo em referencia ele funciona, mas para retornar ao campo do onblur não.
  2. Amigos, na execução do código abaixo, o alert dá a mensagem mas não retorna ao campo, será porque o onblur não aceita retorno paraq o campo acionado ? ex.: No form : <form name="Form2" method="post" action="#" onSubmit="return valida()"> <table id="table1-fcredencia"> <tr> <td COLSPAN="1" width="150">login</td> <td COLSPAN="1" width="80"><input name="xlogin" type="text" required autofocus onchange="condicao(this.value)" style="padding-left:5px" id="xlogin" maxlength="8" size="8" class="textbox" /></td> ... na função : function condicao(){ if(Form2.xlogin.value.length < 6){ alert("Favor Preencher o campo com no mínimo seis dígitos"); document.Form2.xlogin.focus(); return false; } else { alert("Obrigado, "+Form2.xlogin.value); return Form2.xlogin.select(); } }
  3. Tenho a página abaixo que deveria abrir um form para alteração de dados de um "agente", porem acontece o seguinte : A rotina funciona, ela apresenta o form com os dados a serem alterados e no clique do "salvar", ela grava os dados no disco. Até aí tudo bem, acontece que logo após, em vez de encerrar a página e retornar à pagina anterior, ela como se desse um "refresh", repete tudo de novo (aí acontece o erro abaixo : Notice: Undefined variable: id in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\www\new homepage\fagentes\editar.php on line 176 Warning: ibase_fetch_row(): conversion error from string "" in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\www\new homepage\fagentes\editar.php on line 179 Notice: Undefined variable: id in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\www\new homepage\fagentes\editar.php on line 188 Warning: ibase_fetch_assoc(): conversion error from string "" in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\www\new homepage\fagentes\editar.php on line 190 Código da pagina (abreviei alguns dados para diminuir o post) : ============= aqui inicializo a seção e pego o campo id do get com o codigo do agente a ser alterado. <?php session_start(); // Inicia a sessão if (!isset( $_GET['id'] ) || $_GET['id'] == '') {} else { $id = $_GET['id'];} ?> =================== início ============================== <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="css/frame_dados.css" /> <title>alterar agente</title> <script language="javascript" type="text/javascript"> /* valida email */ function validaemail(campo) { --> função de validação do campos e-mail } /* validação dos agentes */ function valida() { função de critica dos dados do form } </script> <style type="text/css"> body { background-color: #ffffff; color: #000000; font-family: arial; font-size: 13px; margin: 0; padding: 0; } <!-- outros styles --> </style> </head> <body> ================ seleciono o registro (agente) cujo codigo foi informado no get ($id=$_GET(['id']) <?php require_once('../db/conexao.php'); $ibasesql = "select a.*, c.cargo_codigo, c.cargo_nome from t_agentes a inner join t_cargos c on a.agente_cod_cargo = c.cargo_codigo where a.agente_codigo = '$id'"; $ibaseresult = ibase_query($conexao, $ibasesql); $j = 0; while (ibase_fetch_row($ibaseresult)) { $j++; // $j= quantidade de registros pra paginação } if ($j > 1) { echo "existem mais de um registro com a chave : " . "$id" . " exclua os registros desnecess⳩os !"; //echo "<a href="javascript:window.history.go(-1)">voltar</a>"; } $ibasesql = "select a.*, c.cargo_codigo, c.cargo_nome from t_agentes a inner join t_cargos c on a.agente_cod_cargo = c.cargo_codigo where a.agente_codigo = '$id'"; $ibaseresult = ibase_query($conexao, $ibasesql); while ($linha = ibase_fetch_assoc($ibaseresult)) { //edita os dados do registro $cod = str_pad($linha["AGENTE_CODIGO"],6,'0',STR_PAD_LEFT); $nome = substr($linha["AGENTE_NOME"], 0, 50); $cargo = $linha["AGENTE_COD_CARGO"]; $inicio = $linha["AGENTE_INICIO"]; $termino = $linha["AGENTE_TERMINO"]; $matricula = str_pad(trim($linha["AGENTE_MATRICULA"]),6,'0',STR_PAD_LEFT); $email = substr($linha["AGENTE_EMAIL"], 0, 50); } if(empty($termino)) { $termino = '0000-00-00'; } function seleciona_item($valor, $campo) { return preg_replace("#<option value=\"$valor\">#is", "<option value=\"$valor\" selected=\"selected\">", $campo); } function monta_select($campo, $start, $end) { $select = "<select name=\"$campo\" id=\"$campo\">\n"; for($i = $start; $i <= $end; $i++) { $select .= "\t<option value=\"". sprintf("%02d", $i) ."\">".sprintf("%02d", $i)."</option>\n"; } $select .= "</select>\n"; return $select; } ?> ===================== montagem do form <div id="geral"> <!-- 0 --> <div id="data-topo"> </div> <!-- fim div topo' --> <div id="data-menu" align="center" style="color: #0900c4; border:1px solid black;height: 30px;"> <span style="color:#0000ff;font-family:arial;font-size:21px;">agentes</span> </div> <div id="data-conteudo"> <div id="data-esquerda" align="center" style="color: #0900c4; border:1px solid black;"> <!-- 3 --> </div> <div id="data-sub-conteudo" align="center" style="color: #0900c4; border:1px solid black;"> </br> <form name="form1" method="post" action="?i=ok" onsubmit="return valida()"> <table width="750" border="0" align="center"> </br></br> <tr> <td width="200">código</td> <td width="500"><input name="codigo" type="text" id="cod" maxlength="6" size="6" class="textbox" value="<?php echo $cod; ?>" /></td> </tr> <tr> <td width="200">nome</td> <td width="500"><input name="nome" type="text" id="nome" maxlength="50"size="90" class="textbox" value="<?php echo $nome; ?>" /></td> </tr> <tr> <td width="200">cargo</td> <td> <select name="p_cargo" class="textbox" size="1" id="combo_cargo" style="top:120px;width:245px;height:19px;line-height:19px;z-index:3;";>; <!-- faz o loop para preencher o campo criado com os valores retornados na consulta --> <?php $sql_cargo = "select * from t_cargos order by cargo_codigo asc"; $result_cargos = ibase_query($conexao,$sql_cargo); while($dados = ibase_fetch_assoc($result_cargos)) { $codc = $dados["CARGO_CODIGO"]; $nomec = $dados["CARGO_NOME"]; if ($codc == $cargo) { echo '<option value="' . $codc . '" selected>' . $nomec . '</option>'; } else { echo '<option value="' . $codc . '">' . $nomec . '</option>'; } } //fecha o campo select echo '</select>'; ?> </td> </tr> <tr> <td>data de início</td> <td> <?php $arr = explode("-", $inicio); echo seleciona_item($arr[2], monta_select("idia", 1, 31)); echo seleciona_item($arr[1], monta_select("imes", 1, 12)); echo seleciona_item($arr[0], monta_select("iano", 1940, 2014)); ?> </td> </tr> <tr> <td>data de término</td> <td> <?php $arr = explode("-", $termino); echo seleciona_item($arr[2], monta_select("tdia", 0, 31)); echo seleciona_item($arr[1], monta_select("tmes", 0, 12)); echo seleciona_item($arr[0], monta_select("tano", 0, 2014)); ?> </td> </tr> <tr> <tr> <td width="200">matrícula</td> <td width="500"><input name="matricula" type="text" id="matricula" maxlength="6" class="textbox" value="<?php echo $matricula; ?>" /></td> </tr> <tr> <td width="200">email</td> <td><input name="email" type="text" id="email" maxlength="45"class="textbox" value="<?php echo $email; ?>" /></td> </tr> <tr> <td></br></br></br></br></br></td> <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp <input type="button" value="&nbsp;&nbsp;&nbsp;voltar&nbsp;&nbsp;&nbsp;" onclick="javascript: location.href='fagentes.php';" > <input name="enviar" type="submit" value="&nbsp;&nbsp;&nbsp;salvar&nbsp;&nbsp;&nbsp;" > <?php ================= aqui eu regravo o agente ============ if ( isset( $_GET['i'] ) && $_GET['i'] == 'ok') { // esta rotina era externa e funcionava perfeitamente bem, agora quero incluir internamente if($_SERVER["REQUEST_METHOD"] == "POST") { $codigo = $_POST["codigo"]; $nome = $_POST["nome"]; $email = $_POST["email"]; $cargo = $_POST["p_cargo"]; $matricula = $_POST["matricula"]; $datai = "{$_POST["iano"]}-{$_POST["imes"]}-{$_POST["idia"]}"; $datat = "{$_POST["tano"]}-{$_POST["tmes"]}-{$_POST["tdia"]}"; if ($datai == '00-00-00') { $datai = date("Y-m-d"); } if ($datat == '00-00-00') { $datat = date("Y-m-d"); } $icodigo = intval($codigo); $ibaseSQL = "SELECT * from p_agentes ('A','$icodigo','$nome','$cargo','$datai', '$datat','$matricula','$email')"; $query = ibase_prepare($ibaseSQL); $rs=ibase_execute($query) or die(ibase_errmsg()); $row = ibase_fetch_row($rs); } // fim da rotina de regravação ?> </td> </tr> </table> </form> </div> <div id="data-direita" align="left" style="color: #0900c4; border:1px solid black;"> <!-- 3 --> </div> </div> </div> </body> </html>
  4. Aos administradores do fórum : Como faço para dar como encerrado um tópico e conceder créditos a ajuda fornecida ? (Fechado à moda "grosseira").
  5. Euler, Obrigado pela ajuda, mas já tinha encontrado o erro (e não era só esse). Outros campos da validação também tinham erros. Tinha colocado uns "echo's" na função e o PHP/JS não executava o comando, daí pensar que não estava executando a validação. Agora sei que quando houver qualquer erro ele ignora toda a função, Agora, "puxando a brasa para o meu peixe", v. olhou a sua cx postal ?. Aquele problema até hoje não resolvi. Se o amigo puder me ajudar, agradeceria bastante.
  6. Amigos, tenho um programa idêntico ao abaixo listado (a diferença esta apenas no fato de que uso apenas div) em que funciona legal o onsubmit, mas nesse abaixo não entra na função. alguém consegue me explicar o porque ? listagem : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Alteração</title> <script language="javascript" type="text/javascript"> /* validação dos agentes */ function valida() { this; var d = document.Form1; if(d.cod.value == "") { alert('Favor preencher o campo de código !.'); d.cod.focus(); return false; } if(d.nome.value == "") { alert('Favor preencher o campo de nome !.'); d.editbox2.focus(); return false; } if(d.getElementById("combo_cargo").selectedIndex == "") { alert('Favor selecionar um cargo para o agente !.'); d.combocargo.focus(); return false; } if(d.email.value == "") { alert('Favor preencher o campo de email !.'); d.email.focus(); return false; } if !(filter_var(d.email.value)) { alert('Favor preencher com email válido !.'); d.email.focus(); return false; } } </script> <style type="text/css"> body { background-color: #FFFFFF; color: #000000; font-family: Arial; font-size: 13px; margin: 0; padding: 0; } </style> <style type="text/css"> a { color: #0000FF; text-decoration: underline; } a:visited { color: #800080; } a:active { color: #FF0000; } a:hover { color: #0000FF; text-decoration: underline; } </style> <style type="text/css"> #wb_Form1 { background-color: #FAFAFA; border: 1px #000000 solid; } #Editbox1 { border: 1px #A9A9A9 solid; background-color: #FFFFFF; color :#000000; font-family: Arial; font-size: 13px; text-align: left; vertical-align: middle; } #Editbox2 { border: 1px #A9A9A9 solid; background-color: #FFFFFF; color :#000000; font-family: Arial; font-size: 13px; text-align: left; vertical-align: middle; } #wb_Text1 { background-color: transparent; border: 0px #000000 solid; padding: 0; text-align: left; } #wb_Text1 div { text-align: left; } #wb_Text2 { background-color: transparent; border: 0px #000000 solid; padding: 0; text-align: left; } #wb_Text2 div { text-align: left; } #Button1 { border: 1px #A9A9A9 solid; background-color: #F0F0F0; color: #000000; font-family: Arial; font-size: 13px; } #wb_Text3 { background-color: transparent; border: 0px #000000 solid; padding: 0; text-align: left; } #wb_Text3 div { text-align: left; } </style> </head> <body> <?php // include_once('conexao.php'); require_once('conexao.php'); if (isset($_GET["id"])) { $id = $_GET["id"]; } else { echo "erro get"; } $ibaseSQL = "SELECT a.*, c.cargo_codigo, c.cargo_nome FROM t_agentes a inner join t_cargos c on a.agente_cod_cargo = c.cargo_codigo where a.agente_codigo = '$id'"; $ibaseResult = ibase_query($conexao, $ibaseSQL); $j = 0; while (ibase_fetch_row($ibaseResult)) { $j++; // $j= Quantidade de registros pra paginação } if ($j > 1) { echo "Existem mais de um registro com a chave : " . "$id" . " Exclua os registros desnecess⳩os !"; //echo "<a href="javascript:window.history.go(-1)">Voltar</a>"; } $ibaseSQL = "SELECT a.*, c.cargo_codigo, c.cargo_nome FROM t_agentes a inner join t_cargos c on a.agente_cod_cargo = c.cargo_codigo where a.agente_codigo = '$id'"; $ibaseResult = ibase_query($conexao, $ibaseSQL); while ($linha = ibase_fetch_assoc($ibaseResult)) { //edita os dados do registro $cod = str_pad($linha["AGENTE_CODIGO"],6,'0',STR_PAD_LEFT); $nome = substr($linha["AGENTE_NOME"], 0, 50); $cargo = $linha["AGENTE_COD_CARGO"]; $inicio = $linha["AGENTE_INICIO"]; $termino = $linha["AGENTE_TERMINO"]; $matricula = str_pad(trim($linha["AGENTE_MATRICULA"]),6,'0',STR_PAD_LEFT); $email = substr($linha["AGENTE_EMAIL"], 0, 50); } if(empty($termino)) { $termino = '0000-00-00'; } ?> <div id="wb_Text3" style="position:absolute;left:450px;top:42px;width:109px;height:24px;z-index:5;text-align:left;"> <span style="color:#0000FF;font-family:Arial;font-size:21px;">Agentes</span></div> <div id="wb_Form1" style="position:absolute;left:214px;top:83px;width:585px;height:318px;z-index:7;"> <form name="Form1" method="post" action="salvar_edicao.php" onSubmit="return valida(this)"> <table width="400" border="0" align="center"> <tr> <td width="145">Código</td> <td width="245"><input name="codigo" type="text" id="cod" maxlength="6" class="textBox" value="<?php echo $cod; ?>" /></td> </tr> <tr> <td width="145">Nome</td> <td width="245"><input name="nome" type="text" id="nome" maxlength="50" class="textBox" value="<?php echo $nome; ?>" /></td> </tr> <tr> <td width="200">Cargo</td> <td> <select name="p_cargo" class="textBox" size="1" id="combo_cargo" style="top:120px;width:245px;height:19px;line-height:19px;z-index:3;";>; <!-- faz o loop para preencher o campo criado com os valores retornados na consulta --> <?php $sql_cargo = "SELECT * from t_cargos order by cargo_codigo asc"; $result_cargos = ibase_query($conexao,$sql_cargo); echo '<option value="' . "0" . '">' . "todos" . '</option>'; while($dados = ibase_fetch_assoc($result_cargos)) { $codc = $dados["CARGO_CODIGO"]; $nomec = $dados["CARGO_NOME"]; if ($codc == $cargo) { echo '<option value="' . $codc . '" selected>' . $nomec . '</option>'; } else { echo '<option value="' . $codc . '">' . $nomec . '</option>'; } } //fecha o campo select echo '</select>'; ?> </td> </tr> <tr> <td>Data de Início</td> <td> <?php $arr = explode("-", $inicio); echo Seleciona_Item($arr[2], monta_select("idia", 1, 31)); echo Seleciona_Item($arr[1], monta_select("imes", 1, 12)); echo Seleciona_Item($arr[0], monta_select("iano", 1940, 2014)); ?> </td> </tr> <tr> <td>Data de Término</td> <td> <?php $arr = explode("-", $termino); echo Seleciona_Item($arr[2], monta_select("tdia", 0, 31)); echo Seleciona_Item($arr[1], monta_select("tmes", 0, 12)); echo Seleciona_Item($arr[0], monta_select("tano", 0, 2014)); ?> </td> </tr> <tr> <tr> <td width="145">Matrícula</td> <td width="245"><input name="matricula" type="text" id="matricula" maxlength="50" class="textBox" value="<?php echo $matricula; ?>" /></td> </tr> <tr> <td width="200">Email</td> <td><input name="email" type="text" id="email" maxlength="64" class="textBox" value="<?php echo $email; ?>" /></td> </tr> <tr> <td>&nbsp;</td> <td><input name="enviar" type="submit" value="Salvar" style="cursor:pointer;position:absolute;left:1050px;top:120px;width:96px;height:25px;z-index:4;" /></td> </tr> </table> <?php function Seleciona_Item($valor, $campo) { return preg_replace("#<option value=\"$valor\">#is", "<option value=\"$valor\" selected=\"selected\">", $campo); } function monta_select($campo, $start, $end) { $select = "<select name=\"$campo\" id=\"$campo\">\n"; for($i = $start; $i <= $end; $i++) { $select .= "\t<option value=\"". sprintf("%02d", $i) ."\">".sprintf("%02d", $i)."</option>\n"; } $select .= "</select>\n"; return $select; } ?> </form> </div> </body> </html>
  7. Euler01, obrigado pela ajuda cara. vlw.
  8. Amigos, alguém sabe olhando o código abaixo porque o combo não exibe o primeiro registro da tabela ? codigo : <?php include('conexao.php'); $sql_cargo = "SELECT * from t_cargos order by cargo_codigo"; ?> <div id="wb_selec" style="position:absolute;left:200px;top:112px;width:71px;height:16px;z-index:3;text-align:left;"> <select name="Combobox1" class="textBox" size="01" id="Combobox1" style="position:absolute;>; </div> //faz o loop para preencher o campo criado com os valores retornados na consulta<br />; <?php $result = ibase_query($conexao,$sql_cargo); while($dados = ibase_fetch_assoc($result)) { $codc = str_pad($dados["CARGO_CODIGO"],6,'0',STR_PAD_LEFT); $nomec = substr($dados["CARGO_NOME"], 0, 50); echo '<option value="' . $codc . '">' . $nomec . '</option>'; } //fecha o campo select e o formulário echo '</select>'; ?>
  9. Grato, agora como faço para lhe dar o crédito e finalizar o tópico ? rsrsr
  10. Agora mais uma "coisinha" : Como faço para substituir o Link (próximo por uma imagem de um botão) ?
  11. Paiva Jr

    Div ou Tabela ?

    E agora, como faço para fechar esse tópico. rsrs
  12. Paiva Jr

    Div ou Tabela ?

    <script type='text/javascript'>window.mod_pagespeed_start = Number(new Date());</script> É euler01, já tinha chegado a essa conclusão, tanto que já estou "apanhando" com as DIV's.
  13. <script type='text/javascript'>window.mod_pagespeed_start = Number(new Date());</script> Euler01, obrigado, era justamente o que estava procurando.
  14. Paiva Jr

    Div ou Tabela ?

    Para organizar a exibição de um Form de dados, qual o ideal ? Utilizar DIV ou Table ? Quais seriam as diferenças entre esses usos ?
  15. Talvez um dos foristas consiga, eu não estou conseguindo (inexperiência ou cansaço). Porque o php não está aceitando as variáveis no caso abaixo : O erro : Notice: Undefined index: box1 in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\www\FireCadastro\salvar2.php on line 6 Notice: Undefined index: EditBox2 in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\www\FireCadastro\salvar2.php on line 7 O form : <body> <div id="wb_Form1" style="position:absolute;left:214px;top:83px;width:585px;height:318px;z-index:7;"> <form name="Form1" method="post" action="salvar2.php" enctype="text/plain" id="Form1"> <input type="text" id="Ed1" style="position:absolute;left:427px;top:29px;width:101px;height:19px;line-height:19px;z-index:0;" name="box1" value="123"> <input type="text" id="Ed2" style="position:absolute;left:427px;top:74px;width:101px;height:19px;line-height:19px;z-index:1;" name="Editbox2" value="nomeqq"> <div id="wb_Text1" style="position:absolute;left:337px;top:33px;width:71px;height:16px;z-index:2;text-align:left;"> <span style="color:#000000;font-family:Arial;font-size:13px;">codigo</span></div> <div id="wb_Text2" style="position:absolute;left:338px;top:77px;width:71px;height:16px;z-index:3;text-align:left;"> <span style="color:#000000;font-family:Arial;font-size:13px;">Nome</span></div> <input type="submit" id="Button1" value="Submit" style="position:absolute;left:352px;top:161px;width:96px;height:25px;z-index:4;"> <div id="wb_Text3" style="position:absolute;left:31px;top:22px;width:109px;height:24px;z-index:5;text-align:left;"> <span style="color:#0000FF;font-family:Arial;font-size:21px;">Agentes</span></div> </form> </div> </body> O Action (salvar2.php) : <?php if($_SERVER["REQUEST_METHOD"] == "POST") { $codigo = $_POST['box1']; $nome = $_POST["EditBox2"]; } if(file_exists("init.php")) { require "init.php"; } else { echo "Arquivo init.php não foi encontrado"; exit; } include('conexao.php'); obs;: já tentei como Ed1, box1, etc...
×
×
  • Criar Novo...