
Romerito
Membros-
Total de itens
429 -
Registro em
-
Última visita
Tudo que Romerito postou
-
i aew Rafael Laurindo, tem o LOAD DATA INFILE, acho que ele vai te servir. falow abraço!
-
ok, valeu carinha!
-
i aew carinha, então eu olhei seu codigo tem alguns erros no HTML, tipo assim: você tem ID´s com o mesmo nome, depois procura a respeito para ter mais detalhes, bom basicamente os erros são por conta disso. Testa com esse codigo aqui: $( document ).ready( function(){ $( '.line' ).each( function(){ $( this ).children( 'div:eq(4)' ).find( 'a' ).click( function(){ var oImg = $( this ).children( 'img' ); $( oImg ).attr( 'src' , ( $( oImg ).attr( 'src' ) == 'img/detalhes.jpg' ? 'img/detalhes.jpg' : 'img/detalhesHIDE.jpg' ) ); var href = $( this ).attr( 'href' ).replace( /(.*\#)/, '' ); $( '#' + href ).toggle( "slow" ); } ); } ); } ); desse jeito acho que funciona, mas não vai esquecer de arrumar as ID´s com nomes duplicados. falow abraço!
-
i aew carinha, então, testa tipo assim: <html> <head> <title>title</title> <script type='text/javascript' src='jquery-1.3.2.min.js' ></script> <script language="Javascript"> $( document ).ready( function(){ $( "a#teste" ).click( function(){ $( this ).children( 'img' ).attr( 'src' , ( $( this ).children( 'img' ).attr( 'src' ) == 'imagem1.jpg' ? 'imagem2.jpg' : 'imagem1.jpg' ) ) ; var href = $( this ).attr( 'href' ).replace( /(.*\#)/, '' ); $( '#' + href ).toggle( "slow" ); } ) }); </script> </head> <body> <a id='teste' href='#esconde' /><img src='imagem1.jpg' /></a> <div id='esconde' style='background:green;display:none;width:200px;height:200px'>teste</div> </body> </html> espero que ajude, falow!
-
tipo assim, o LEFT JOIN preserva as linhas da tabela da esquerda, no caso "funcionario" e descarta as da direita quando não tem nehum valor correspondênte. sou meu ruim para explicar, mas qualquer coisa da uma googlada! falow abraço!
-
tenta tipo assim: SELECT d.nome, CASE WHEN ( f.planosaude = '' ) THEN '-' ELSE ps.nome END AS planosaude FROM funcionario f LEFT JOIN dependente d ON ( f.codigo = d.funcionario ) LEFT JOIN planosaude ps ON ( f.planosaude = ps.codigo );
-
i aew AndréSAP, bom esse código deveria funcionar, tem certeza que você não esta confundido o campo vazio com null? testa tipo assim: SELECT d.nome, CASE WHEN ( f.planosaude = '' ) THEN '-' ELSE ps.nome END AS planosaude FROM funcionario f JOIN dependente d ON ( d.funcionario = f.codigo ) JOIN planosaude ps ON ( f.planosaude = ps.codigo ); espero que ajude abraço!
-
i aew Darela, tenta usar tipo assim: <html> <head> <title>title</title> <script type='text/javascript' src='jquery-1.3.2.min.js' ></script> <script language="Javascript"> $( document ).ready( function(){ $( "a#teste" ).click( function(){ $( this ).text( ( $( this ).text() == 'aparece' ? 'esconde' : 'aparece' ) ); var href = $( this ).attr( 'href' ).replace( /(.*\#)/, '' ); $( '#' + href ).toggle( "slow" ); } ) }); </script> </head> <body> <a id='teste' href='#esconde' />aparece</a> <div id='esconde' style='background:green;display:none;width:200px;height:200px'>teste</div> </body> </html> espero que ajude abraço!
-
i aew pessoal, bom tenho visto nos ultimos tempos a galera perguntando muito como pegar a diferença entre datas no php, bom eu criei isso no inicio do ano(01/2010), e vim aqui compartilhar com vocês, espero que ajude a galera, eu usei ela em alguns casos e nunca tive problemas, mas qualquer bug coloca aew para resolvermos. Falow! TimeStammpDiff.php /** * Description of TimeStampDiff * * Classe para retornar difernça entre datas, semelhante ao TimeStampDiff do MySql. * * @author Rogério Avelino da Silva <avelino_rogerio@yahoo.com.br> * @category Data * @version 1.0 * @see 2010-01-04 */ class TimeStampDiff { /** * É a string da primeira data passado como parametro * @access protected * @var string */ protected $time = null; /** * É a string da segunda data passado como parametro * @access protected * @var string */ protected $timeDiff = null; /** * Vai guardar a primeira data passado como parametro, em segundos * @access protected * @var int */ protected $timeSegundos; /** * Vai guardar a segunda data passado como parametro, em segundos * @access protected * @var int */ protected $timeSegundosDiff; /** * Vai guardar a quantidade de dias bissexto em segundos * @access protected * @var int */ protected $timeDiffBisSegundos; /** * Vai guardar a quantidade de bissextos * @access protected * @var int */ protected $bissextoD; /** * Vai guardar em um array todos os anos bissextos * @access protected * @var array */ protected $anosBissexto; /** * Vai guardar a diferença das datas em anos * @access protected * @var int */ protected $anosDiff; /** * Vai guardar a diferença das datas em meses * @access protected * @var int */ protected $mesDiff; /** * Vai guardar a diferença das datas em semanas * @access protected * @var int */ protected $semanaDiff; /** * Vai guardar a diferença das datas em dias * @access protected * @var int */ protected $diaDiff; /** * Vai guardar a diferença das datas em dias * @access protected * @var int */ protected $horaDiff; /** * Vai guardar a diferença das datas em minutos * @access protected * @var int */ protected $minutoDiff; /** * Vai guardar a diferença das datas em segundos * @access protected * @var int */ protected $segundoDiff; const DIAS_ANO = 365; const SEGUNDOS_DIA = 86400; const SEGUNDOS_HORA = 3600; const SEGUNDOS_MINUTO = 60; /** * Constructor * Deve se passar as pelo menos a primeira string no formato YYYY-MM-DD HH:II:SS * @param String $time * @param String $timeDiff */ public function __construct( $time , $timeDiff = null ) { if ( !$timeDiff ) $timeDiff = date( 'Y-m-d H:i:s' ); $this->setTime( $time ); $this->setTime( $timeDiff ); $this->setTimesSegundos(); $this->calculaDiff(); } /** * getDiffDatas() * É o método principal que retorna a diferença das datas no formato deseja * @access protected * @param string $strTipo * @return int | array | string */ public function getDiffDatas( $strTipo ) { switch ( strtolower( $strTipo ) ) { case 'num_anos_bissextos' : return $this->bissextoD; case 'anos_bissextos' : return $this->anosBissexto; case 'anos' : return $this->anosDiff; case 'meses' : return $this->mesDiff; case 'semanas' : return $this->semanaDiff; case 'dias' : return $this->diaDiff; case 'horas' : return $this->horaDiff; case 'minutos' : return $this->minutoDiff; case 'segundos' : return $this->segundoDiff; default : return "A string passada como parametro ({$strTipo}) não existe! Verifique o método getDiffDatas para ver os parametros aceitos."; } } /** * setTime() * verifica se a string passada esta em um formato de data e seta um valor a propriedade * @access protected * @throws exceptionclass se a data não estiver no formato vai ser lançada a exceção * @param string $time */ protected function setTime( $time ) { if ( !$this->isTimeString( $time ) ) { throw new Exception( "A hora não esta em um formato válido: <b>{$time}</b>" ); } else { ( isset( $this->time ) ) ? $this->timeDiff = $time : $this->time = $time; } } /** * isTimeString() * verifica se a string passada esta em um formato de data * @access protected * @return boolean */ protected function isTimeString( $time ) { return ( preg_match( '/(^\d{4}\-\d{2}\-\d{2}(\s\d{2}\:\d{2}\:\d{2})?$)|(^\d{2}:\d{2}(:\d{2})?$)/' , $time ) ) ? true : false; } /** * setTimesSegundos() * seta as propriedades timeSegundos, timeSegundosDiff e segundoDiff * @access protected */ protected function setTimesSegundos() { $this->timeSegundos = strtotime( $this->time ); $this->timeSegundosDiff = strtotime( $this->timeDiff ); $this->segundoDiff = $this->timeSegundosDiff - $this->timeSegundos; } /** * calculaDiff() * seta as propriedades: timeDiffBisSegundos, anosBissexto, diaDiff * bissextoD, anosDiff, mesDiff, semanaDiff, horaDiff e minutoDiff * @access protected */ protected function calculaDiff() { $aBissesxto = $this->getBissextoTime(); $this->timeDiffBisSegundos = $aBissesxto[0]; $this->anosBissexto = $aBissesxto[1]; $this->diaDiff = floor( $this->segundoDiff / self::SEGUNDOS_DIA ); $this->bissextoD = floor( $this->timeDiffBisSegundos / self::SEGUNDOS_DIA ); $this->anosDiff = floor( ( $this->diaDiff - $this->bissextoD ) / self::DIAS_ANO ); $this->mesDiff = $this->getMonth(); $this->semanaDiff = floor( $this->diaDiff / 7 ); $this->horaDiff = floor( $this->segundoDiff / self::SEGUNDOS_HORA ); $this->minutoDiff = floor( $this->segundoDiff / self::SEGUNDOS_MINUTO ); } /** * getBissextoTime() * Faz o calculo para saber quais anos são bissextos * @access protected * @return retorna um array, o primeiro parametro é a quantidade de dias bissexto * convertido em segundos e o segundo parametro retorna um array contendo os anos bissextos */ protected function getBissextoTime() { $iBissexto = 0; $aAnosBiss = array(); $ano = substr( $this->time , 0 , 4 ); $anoDiff = ( is_numeric( substr( $this->timeDiff , 0 , 4 ) ) ) ? substr( $this->timeDiff , 0 , 4 ) : date( 'Y' ); if ( is_numeric( substr( $ano , 0 , 4 ) ) ) { while ( $ano <= $anoDiff ) { if ( ( ( $ano % 4) == 0 && ( $ano % 100 ) != 0 ) || ( $ano % 400 ) == 0 ) { $iBissexto += self::SEGUNDOS_DIA; $aAnosBiss[] = $ano; } $ano++; } } return array( $iBissexto , $aAnosBiss ); } /** * getMonth() * calcula a diferença das datas * @access protected * @return retorna diferença das datas em meses */ protected function getMonth() { $iAnoIni = (int) substr( $this->time , 0 , 4 ); $iAnoDiff = (int) substr( $this->timeDiff , 0 , 4 ); $iMesIni = (int) substr( $this->time , 5 , 2 ); $iMesDiff = (int) substr( $this->timeDiff , 5 , 2 ); $iDiaIni = (int) substr( $this->time , 8 , 2 ); $iDiaDiff = (int) substr( $this->timeDiff , 8 , 2 ); $iTotMes = 0; while ( $iAnoIni <= $iAnoDiff ) { $i = ( $iAnoIni == substr( $this->time , 0 , 4 ) ) ? ( $iMesIni + 1 ) : 1; for (; $i <= 12; $i++ ) { if ( $iAnoIni >= $iAnoDiff && $i >= $iMesDiff ) { if ( $iDiaIni <= $iDiaDiff && ( $iMesIni != $iMesDiff || substr( $this->time , 0 , 4 ) != $iAnoDiff ) ) $iTotMes++; break; } else { for ( $j = 1; $j <= 31; $j++ ) { if ( ( $j + 1 ) > $iDiaIni ) { $iTotMes++; break; } } } } $iAnoIni++; } return $iTotMes; } } Exemplos de uso: $dataMenor = '1984-02-21 13:21:45'; $dataMaior = '2005-02-21 22:32:56'; $oTimeStampDiff1 = new TimeStampDiff( $dataMenor , $dataMaior ); echo "Diferença entre as datas {$dataMenor} e {$dataMaior}.<br />"; //retorna a diferença em anos echo "anos: " . $oTimeStampDiff1->getDiffDatas( 'anos' ) . "<br />"; //retorna a diferença em meses echo "meses: " . $oTimeStampDiff1->getDiffDatas( 'meses' ) . "<br />"; //retorna a diferença em semanas echo "semanas: " . $oTimeStampDiff1->getDiffDatas( 'semanas' ) . "<br />"; //retorna a diferença em dias echo "dias: " . $oTimeStampDiff1->getDiffDatas( 'dias' ) . "<br />"; //retorna a diferença em horas echo "horas: " . $oTimeStampDiff1->getDiffDatas( 'horas' ) . "<br />"; //retorna a diferença em minutos echo "minutos: " . $oTimeStampDiff1->getDiffDatas( 'minutos' ) . "<br />"; //retorna a diferença em segundos echo "segundos: " . $oTimeStampDiff1->getDiffDatas( 'segundos' ) . "<br />"; //retorna o numero de dias bissextos echo "numero de dias bissexto: " . $oTimeStampDiff1->getDiffDatas( 'num_anos_bissextos' ) . "<br />"; //retorna a todos os anos bissextos em um array $aAnosBissextos = $oTimeStampDiff1->getDiffDatas( 'anos_bissextos' ); //tambem pode usuar um count para saber a quantidade de dias bissextos echo "numero de dias bissexto: " . count( $aAnosBissextos ) . "<br />"; echo "anos bissextos:" . implode( ',' , $aAnosBissextos ); echo '<hr />'; //tambem pode passar somente as horas $oTimeStampDiff2 = new TimeStampDiff( '12:00:00' , '17:40:00' ); echo 'Diferença entre 12:00:00 e17:40:00, em horas: ' . $oTimeStampDiff2->getDiffDatas( 'horas' ) . '<br />'; //tambem pode passar no formato YYYY-MM-DD e YYYY-MM-DD HH:II:SS $oTimeStampDiff3 = new TimeStampDiff( '2010-04-09' , '2010-04-09 12:43:07' ); echo 'Diferença entre 2010-04-09 e 2010-04-09 12:43:07, em minutos: ' . $oTimeStampDiff3->getDiffDatas( 'minutos' ) . '<br />'; //tambem pode passar no formato YYYY-MM-DD e YYYY-MM-DD HH:II:SS $oTimeStampDiff4 = new TimeStampDiff( '2005-03-12' , '2010-04-09' ); echo 'Diferença enre 2005-03-12 e 2010-04-09 em meses: ' . $oTimeStampDiff4->getDiffDatas( 'meses' ) . '<br />'; //tambem pode passar somente a o primeiro parametro //o segundo parametro ira assumir como default a data e hora atual. $oTimeStampDiff5 = new TimeStampDiff( '2010-03-27' ); echo 'Diferença enre 1992-03-27 e a data atual em semanas: ' . $oTimeStampDiff5->getDiffDatas( 'semanas' ) . '<br />';
-
i aew Anãod®é™, bom tenta tipo assim: <html> <head> <title>banner rotativo</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="Javascript"> window.onload = function(){ setInterval( 'Banners()' , 1000 );/*o segundo parametro é de quanto em quanto tempo ele vai executar a funcao*/ } function Banners(){ var MNews = new Array(); MNews[0]= '<A HREF="imagem1.ext" target="_blank"><IMG SRC="imagem1.ext" WIDTH=169 HEIGHT=355 BORDER=0 ALT="texto"></a>'; MNews[1]= '<A HREF="imagem2.ext" target="_blank"><IMG SRC="imagem2.ext" WIDTH=169 HEIGHT=355 BORDER=0 ALT="texto"></a>'; var Numero = Math.floor(Math.random()*2); document.getElementById( 'banner' ).innerHTML = MNews[Numero]; } </script> </head> <body bgcolor="#FFFFFF" topmargin=0 leftmargin=0 text="#000000"> <table width="169" border="0" cellspacing="0" cellpadding="0" height="355" bordercolor="#000000"> <tr> <td> <div id='banner' align="center"></div> </td> </tr> </table> </body> </html> falow abraço!
-
(Resolvido) window.onload = nomefuncao;
pergunta respondeu ao Vagner Nunes de Romerito em Ajax, JavaScript, XML, DOM
i aew Vagner Nunes, bom tenta tipo assim: <script type="text/javascript"> $(document).ready(function() { nomefuncao(); }); function nomefuncao() { var navItems1 = document.getElementById("primary-nav").getElementsByTagName("li"); for (var i=0; i<navItems1.length; i++) { if(navItems1[i].className == "menuparent") { navItems1[i].onmouseover=function() { this.className += " over"; } navItems1[i].onmouseout=function() { this.className = "menuparent"; } } } } </script> espero que ajude abraço! -
(Resolvido) Ajax com Jquery
pergunta respondeu ao Thishinoda de Romerito em Ajax, JavaScript, XML, DOM
i aew Thishinoda, bom conheço 2 maneiras de fazer isso , poder chamar o codigo no final da sua pagina da requisição, dessa maneira: <script type="text/javascript"> $('#galeria a').lightBox(); </script> ou pode colocar no retorno da sua chamada ajax, tipo assim: $.ajax( { url : 'caminho/pagina' , type : 'POST' , dataType : 'html' , success : function( htm ){ $( '#conteudo' ).html( htm ); $('#galeria a').lightBox(); } } ); espero que ajude abraço! -
po carinha se você conseguir setar o cookie ou sessao é só fazer uma checagem dentro do retorno da funcao ajax, tipo assim: $("select[name=estado]").change(function(){ $("select[name=cidade]").html('<option value="0">Carregando...</option>'); $.post("cidades.php", {estado:$(this).val()}, function(valor){ $("select[name=cidade]").html(valor); if ( cookie_cidade ) { $("select[name=cidade] option" ).each( function(){ if ( cookie_cidade == $( this ).val() ) { $( this ).attr( 'selected' , true ); return; } } ); } } ) }).trigger( 'change' ); falow, abraço!
-
entendeu, tenta criar um cookie ou uma sessao da cidade selecionada e depois preencher o combo!
-
validação não é realizada dos campos do formulario não é realizada
pergunta respondeu ao ANDRE_GUSTAVO de Romerito em Ajax, JavaScript, XML, DOM
i aew ANDRE_GUSTAVO, bom provalvelmente o erro esteja na função do DW ou na ID da div que recebe a var texto, tente trocar erro por msgerro, deixa seu bloco mais ou menos assim: if ( erro == 1 ) { try { document.getElementById('msgerro').innerHTML = texto; MM_effectAppearFade('msgerro', 1000, 0, 100, false); //função gerada pelo dreamweaver para o efeito fadein na div } catch(e){ alert( e ); } finally{ return false; } } espero que ajude abraço! -
não entende a pergunta, qual campo ele esta trazendo em branco?
-
i aew carinha tenta tipo assim: $(document).ready(function(){ $("select[name=estado]").change(function(){ $("select[name=cidade]").html('<option value="0">Carregando...</option>'); $.post("cidades.php", {estado:$(this).val()}, function(valor){ $("select[name=cidade]").html(valor); } ) }).trigger( 'change' ); }) percebeu que só adicionamos o método trigger no objeto select estado, espero que que ajude abraço!
-
i aew AlexSandroJAP, quando você capturar o erro você pode utilizar a função trigger, que faz com que uma evento seja executado, ficaria mais ou menos assim: $( '#seu_select_com_evento_onchange' ).trigger( 'change' ); qualquer coisa olha na documentação do jquery abraço!
-
Popup e fechamento automático
pergunta respondeu ao weslley clyton de Romerito em Ajax, JavaScript, XML, DOM
i aew weslley clyton, ve sobre esse carinha aqui, espero que ajude abraço! -
i aew Andryon PHProgrammer, bom se a string tiver um padrão tenta usar RE, tipo assim: $str = "RES SMD 0402 200R 1/16W LF CD:24906 NF:74952"; $arr = preg_split( "/^(\S+\s){6}/", $str , -1 , PREG_SPLIT_OFFSET_CAPTURE ); $str1 = substr( $str , 0 , ( $arr[1][1] - 1 ) ); $str2 = $arr[1][0]; echo "{$str1} <br />"; echo $str2; espero que ajude, abraço!
-
i aew bento, então peguei o seu script e fiz umas pequenas modificações, testa aew pra ver se vai: var varEditar = 0; var d = document; var idLinha = 1; function validaForm(){ var oElems = d.cadastro.elements; for ( var i = 0; i < ( oElems.length - 2 ); i++ ) { if ( oElems[i].value == "" ) { alert( "O campo " + oElems[i].id + " deve ser preenchido!" ); oElems[i].focus(); return false; } } TabelaCadastro(); return true; } function TabelaCadastro(){ if ( varEditar ) { deletar( varEditar ); varEditar = 0; } var oTable = d.getElementById( 'tabela' ); var varbotao1 = d.createElement( 'input' ); varbotao1.setAttribute( 'type' , 'button' ); varbotao1.setAttribute( 'value' , 'Editar' ); var iCnt = idLinha++; varbotao1.onclick = function(){ editar( iCnt ) }; var varbotao2 = d.createElement( 'input' ); varbotao2.setAttribute( 'type' , 'button' ); varbotao2.setAttribute( 'value' , 'Excluir' ); varbotao2.onclick = function(){ deletar( iCnt ) }; var oDiv = d.createElement( 'div' ); oDiv.appendChild( varbotao1 ); oDiv.appendChild( varbotao2 ); var novaLinha = oTable.insertRow( -1 ); novaLinha.setAttribute( 'id' , 'row' + iCnt ); novaLinha.insertCell(0).appendChild( oDiv ); var oFrm = d.cadastro; for ( var i = 0; i < ( oFrm.elements.length - 2 ); i++ ) novaLinha.insertCell( i + 1 ).innerHTML = oFrm.elements[i].value; } function deletar( idRow ) { var iRow = d.getElementById( 'row' + idRow ).rowIndex; d.getElementById( 'tabela' ).deleteRow( iRow ); } function editar( idRow ) { var oElems = d.cadastro.elements; var oTable = d.getElementById( 'tabela' ); var iRow = d.getElementById( 'row' + idRow ).rowIndex; var oTr = oTable.rows[ iRow ]; var oTds = oTr.cells; for ( var i = 1 , j = 0; i < oTds.length; i++ , j++ ) { oElems[j].value = oTds[i].innerHTML; varEditar = iRow; } } qualquer coisa posta aew, abraço!
-
que tipo de erro esta dando cara?
-
i aew carinha, pega o que o Dr_H0us3 fez joga no textarea, bom segue um exemplo pegando sua duvida anterior: <html> <head> <script type='text/javascript'> window.onload = function(){ tagLines = new Array(2); tagLines[0] = "Já está muito de difícil de achar os pandas na Amazônia."; tagLines[1] = "A natureza brasileira só tem 500 anos e já está quase se acabando."; document.getElementById( 'ta' ).innerHTML = tagLines[ Math.floor( Math.random() * tagLines.length ) ] ; } </script> </head> <title>Pagina</title> <body> <textarea cols='40' rows='5' id='ta'></textarea> </body> </html> falow abraço!
-
desabiltar um botão submit (ou button) de um formulario
pergunta respondeu ao Carlos Rocha de Romerito em Ajax, JavaScript, XML, DOM
i aew carinha não sei se entende muito bem, mas vou tentar dar um exemplo, saca só: <?php $s1 = 'true'; $s2 = 'false'; ?> <html> <head> <script type='text/javascript'> window.onload = function(){ var phpS = [ '<?php echo $s1 ?>' , '<?php echo $s2 ?>' ]; var oFrms = document.getElementsByTagName( 'form' ); var oFieldsForm = null; for ( var i = 0; i < oFrms.length; i++ ) { oFieldsForm = oFrms[i].elements; for ( var j = 0; j < oFieldsForm.length; j++ ) { if ( oFieldsForm[j].type == 'submit' ) { oFieldsForm[j].disabled = ( phpS[i] == 'true' ) ? true : false; } } } } </script> </head> <title>Pagina</title> <body> <form name="frm1" > <input type="submit" value='form1'/> </form> <form name="frm2" > <input type="submit" value='form2'/> </form> </body> </html> qualquer coisa posta aew, abraço! -
tipo assim, tu precisa pegar umas aulas de logica de programação ein carinha rsrs. é só remover o caracter de escape e as aspas apos ela, ficando assim: tagLines[1] = "A natureza brasileira só tem 500 anos e já está quase se acabando."; falow meu chapa!