Ir para conteúdo
Fórum Script Brasil

Tenko

Membros
  • Total de itens

    638
  • Registro em

  • Última visita

Tudo que Tenko postou

  1. Tenko

    Como ler tag xml

    livros.xml <?xml version="1.0" encoding='utf-8'?> <livros> <livro> <cod>01</cod> <titulo>PHP</titulo> <descricao>Lendo XML</descricao> <autor>Tenko</autor> <paginas>200</paginas> <preço>5.00</preço> </livro> <livro> <cod>02</cod> <titulo>XML</titulo> <descricao>Usando XML com PHP </descricao> <autor>Jose das Couves</autor> <paginas>100</paginas> <preço>15.00</preço> </livro> </livros> xml.php <?php header ( 'Content-Type:text/html; charset=utf-8' ); $xml = simplexml_load_file ( 'livro.xml' ); foreach ( $xml->livro as $livro ) { echo $livro->cod . '<br/>'; echo $livro->titulo . '<br/>'; echo $livro->autor . '<br/>'; echo $livro->descricao . '<br/>'; echo $livro->preço . '<br/>'; echo "<br>"; } ?>
  2. Boa tarde. Clique encima do projeto com o botão direito do mouse e delete.
  3. Bom dia. Já pesquisou por toFixed(2);
  4. Bom dia. Espero que te ajude. <!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=iso-8859-1"> <title>Untitled Document</title> <script> var d = document; function calcula() { // Inicio zerando os valores d.getElementById( 'total' ).innerHTML = 'R$ 0.00'; // Pegandos os campos var oChecks = d.getElementsByTagName( 'input' ); var iChecks = oChecks.length; var fTotal = 0; // Lendo os dados marcados for( var i = 0; i < iChecks; i++ ) { if( oChecks[ i ].type == 'checkbox' && oChecks[ i ].checked ) { // Separando pelo id passado var separaInfo = oChecks[ i ].id.split( '_' ); // pegando o valor de cada linha var fValorLinha = d.getElementById( 'val' + separaInfo[ 1 ] ).value; // tratando para ver se foram informados valores fValorLinha = parseFloat( fValorLinha ); if( ! isNaN( fValorLinha ) ) { fTotal += fValorLinha; } else { d.getElementById( 'val' + separaInfo[ 1 ] ).value = 0; } } } d.getElementById( 'total' ).innerHTML = 'R$ ' + fTotal.toFixed( 2 ); } </script> </head> <body> <table width="100%" border="1"> <tr> <td width="4%" align="center" valign="middle"><div align="center"> <input name="chk_1" type="checkbox" id="chk_1" value="checkbox"> </div></td> <td width="96%"><input name="val1" type="text" id="val1"></td> </tr> <tr> <td align="center" valign="middle"><div align="center"> <input name="chk_2" type="checkbox" id="chk_2" value="checkbox"> </div></td> <td><input name="val2" type="text" id="val2"></td> </tr> <tr> <td align="center" valign="middle"><div align="center"> <input name="chk_3" type="checkbox" id="chk_3" value="checkbox"> </div></td> <td><input name="val3" type="text" id="val3"></td> </tr> <tr> <td align="center" valign="middle"><div align="center"> <input name="chk_4" type="checkbox" id="chk_4" value="checkbox"> </div></td> <td><input name="val4" type="text" id="val4"></td> </tr> <tr> <td align="center" valign="middle"><div align="center"> </div></td> <td>&nbsp;</td> </tr> <tr> <td align="center" valign="middle"><div align="center">Total</div></td> <td> <span id="total"></span> </td> </tr> <tr> <td colspan="2"><input type="button" value="Calcular" onclick="calcula()"/></td> </tr> </table> </body> </html>
  5. Bom dia. Vê se ajuda. function increaseFontSize() { var p = document.getElementsByTagName('p'); for(i=0;i<p.length;i++) { if( p.id == 'conteudo' ) { if( p.style.fontSize ) { var s = parseInt(p.style.fontSize.replace("px","")); } else { var s = 12; } if( s != max ) { s += 1; } p.style.fontSize = s+"px" } } } <p id="titulo">Teste</p> <p id="titulo1">Teste</p> <p id="conteudo">Teste</p> <p id="rodape">Teste</p>
  6. Tenko

    Erro em anexo com PDF

    É... ainda mesmo vendo o link que você passou não esta abrindo.. Mesmo assim obrigado
  7. Tenko

    Erro em anexo com PDF

    E ai, beleza? Então, o email chega, chega o anexo, mas quando tento abrir, olha ai: O Adobe Reader não pode abrir 'nome_arq.pdf' porque não há suporte a esse tipo de arquivo ou ele foi danificado(por exemplo, foi enviado como anexo de e-mail e não foi decodificado corretamente).. Palavra por palavra
  8. Tenko

    Erro em anexo com PDF

    Boa tarde pessoal, beleza? Preciso de ajuda, fiz este script, funciona para enviar qualquer arquivo, menos PDF, podem me ajudar a saber onde esta errado por favor. Abraços public function montaEmailAnexo( $sPasta ) { $boundary = "XYZ-" . date ( "dmYis" ) . "-ZYX"; $this->headers = "From: {$this->de};" . "\n"; $this->headers .= "MIME-Version: 1.0" . "\n"; $this->headers .= "Content-Type: multipart/mixed;"; $this->headers .= "boundary={$boundary}" . "\n"; $this->headers .= "{$boundary}" . "\r\n"; $this->corpoMSG = "--$boundary" . "\r\n"; $this->corpoMSG .= "{$this->mensagem}" . "\r\n\r\n"; $this->corpoMSG .= "$boundary" . "\r\n"; $this->corpoMSG .= "Content-Type: text/html; charset='iso-8859-1'" . "\r\n"; $this->corpoMSG .= "Content-Transfer-Encoding: quoted-printable" . "\r\n"; $this->corpoMSG .= "Content-description:Mail message body" . "\r\n"; $this->corpoMSG .= "Content-Transfer-Encoding: 8bits" . "\r\n"; $this->corpoMSG .= "--$boundary" . "\r\n"; $sType = ( in_array( $sPasta, array( '../Arquivos/Pedidos/', '../Arquivos/Trocas/' ) ) ) ? 'Application/pdf' : ''; for($i = 0; $i < count ( $this->arquivos ); $i ++) { // [ 06/10/2011 13:44:47 ] Comentário : Abrindo a pasta onde os arquivos estão para gerar os anexos $oFp = fopen ( "{$sPasta}{$this->arquivos [$i]}", 'rb' ); if( $oFp ) { $fread = fread ( $oFp, filesize ( "{$sPasta}{$this->arquivos [$i]}" ) ); // [ 06/10/2011 13:45:09 ] Comentário : Criptografando os anexos para não serem lidos por outra pessoa durante o processo de entrega $this->anexos = base64_encode ( $fread ); $this->anexos = chunk_split( $this->anexos ); $this->corpoMSG .= "Content-Type:{$sType}; name={$this->arquivos [$i]}" . "\r\n"; $this->corpoMSG .= "Content-Transfer-Encoding: base64" . "\r\n"; $this->corpoMSG .= "Content-Disposition: attachment; filename={$this->arquivos [$i]}" . "\r\n"; $this->corpoMSG .= "{$this->anexos}" . "\n"; $this->corpoMSG .= "--{$boundary}--" . "\r\n"; } else { echo 'Erro ao abrir o arquivo...'; return false; } fclose ( $oFp ); } if (! @mail ( $this->para, $this->assunto, $this->corpoMSG, $this->headers )) { return false; } else { return true; } } Antes que eu esqueça... O erro que aparece é: Arquivo não pode ser aberto por estar danificado ou não foi decodificado corretamente
  9. Boa tarde. você colocou o código javascript entre as tags <script> e </script>?
  10. Tenko

    Duvida

    Bom dia. Pesquise por comando sql SELECT, seria algo assim: $sSql = "select * from login WHERE login = '{$sUsuario}' and senha = '{$sSenha}'";
  11. Bom dia, Vê se é isso que você precisa <html> <head> <title></title> <script> var nomes_json = '[{"nome":"Kellen","idade":26},{"nome":"Tenko","idade":30}]'; var lista = eval( nomes_json ); for( var i = 0; i < lista.length; i++ ) { alert( 'Nome : ' + lista[ i ].nome + ' Idade : ' + lista[ i ].idade ); } </script> </head> </html>
  12. deixei bem comentado pra você entender passo a passo o que eu fiz
  13. Falo... precisando estamos ai
  14. Boa tarde. O melhor modo de fazer isso é com AJAX, mas acredito que este modelo te ajude a entender. Deixei tudo com comentários pra ficar fácil de enteder, mas, lembrando, este é um exemplo, procure, pesquise soluções melhores. <html> <head> <title></title> <script> function cidade(estado) { // Criando o array das cidades var aArrayCidade = new Array(); // Adicionando as cidades aArrayCidade['RS'] = new Array('Alecrim','Cacequi','Pinhal Grande'); aArrayCidade['SC'] = new Array('Tubarão', 'Itajaí'); // pega a quantidade de itens do array de cidades do estado var iTamanho = aArrayCidade[ estado ].length; // limpando os campos das cidades document.getElementById('cidade').innerHTML = ''; // Criando e adicionando o primeiro valor oOptions = document.createElement('option'); oOptions.value = ''; oOptions.innerHTML = ':: Selecione ::'; document.getElementById('cidade').appendChild( oOptions ); // percorrendo o array for( var i = 0; i < iTamanho; i++ ) { // criando os objetos options oOptions = document.createElement('option'); oOptions.value = aArrayCidade[ estado ][ i ]; oOptions.innerHTML = aArrayCidade[ estado ][ i ]; // adicionando os elementos document.getElementById('cidade').appendChild( oOptions ); } } </script> </head> <body> <table border="1" cellpadding="1" cellspacing="1" width="40%"> <tr> <td>ESCOLHA UM ESTADO: </td> <td> <select id="estados" onchange="cidade(this.value);"> <option value="">:: Selecione ::</option> <option value="RS">RS</option> <option value="SC">SC</option> </select> </td> </tr> <tr> <td>ESCOLHA A CIDADE: </td> <td> <select id="cidade"> <option value="">:: Selecione ::</option> </select> </td> </tr> </table> </body> </html>
  15. Bom dia, beleza? Fiz um modo simples para você entende, mas existem mais soluções. <html> <head> <title></title> &lt;script> vetor_ficticio = ["joao %% 2011-08-01 %% 10", "jose %% 2011-09-01 %% 15", "maria %% 2011-10-01 %% 20", "pedro %% 2011-08-01 %% 18", "rodrigo %% 2011-10-01 %% 23"]; function quebra( vetor_ficticio ){ var iTamanho = vetor_ficticio.length; var arrayNomes = new Array(); var arrayData = new Array(); var arrayIdade = new Array(); for( var i = 0; i < iTamanho; i++ ){ var aDivisao = vetor_ficticio[ i ].split( '%%' ); arrayNomes.push( aDivisao[ 0 ] ); arrayData.push( aDivisao[ 1 ] ); arrayIdade.push( aDivisao[ 2 ] ); } alert( arrayNomes ); alert( arrayData ); alert( arrayIdade ); } quebra( vetor_ficticio ); </script> </head> <body> </body> </html>
  16. Tenko

    Navegação em site

    Boa tarde. Pode ser feito sim em PHP, mas o que você esta vendo ali não é nada mais que java script: Os arquivos são: js/jquery-1.3.2.min.js js/nav.js Dá até para pegar no site, basta entrar nas pastas
  17. Tenko

    (Resolvido) Delimitador

    MTavares, beleza? Se o arquivo que você esta lendo estiver como você esta falando: ruibarbosa@servidor.com.br; fernandopessoa@servidor.com.br ruthcardoso@servidor.com.br; carloschagas@servidor.com.br Um email por linha, você pode dividi-los de outras forma, pode ser assim: $dividir = explode("\n",$conteudo); Assim você pegaria todos
  18. Tenko

    (Resolvido) Delimitador

    Boa tarde. Tente usar: http://br2.php.net/manual/pt_BR/function.strpos.php
  19. Boa tarde. Vê se isso te da uma luz.. <!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=iso-8859-1"> <title>Teste</title> <script> function filmes(){ var sDados = document.getElementById('filmes').value; if( sDados != '' ) { var aDados = sDados.split('|'); document.getElementById('id').value = aDados[0]; document.getElementById('genero').value = aDados[1]; document.getElementById('filme').value = aDados[2]; } else { document.getElementById('id').value = ''; document.getElementById('genero').value = ''; document.getElementById('filme').value = ''; } } </script> </head> <body> <p> <select name="select" onChange="filmes();" id="filmes"> <option value="">:: Informe ::</option> <option value="1|Comedia|Gente Grande">Gente Grande</option> <option value="2|Ação|Matrix">Matrix</option> </select> </p> <table width="100%" border="0"> <tr> <td width="11%">C&oacute;digo</td> <td width="89%"><input name="id" type="text" id="id" size="5" readonly="readonly"></td> </tr> <tr> <td>Genero</td> <td><input name="genero" type="text" id="genero" size="50"></td> </tr> <tr> <td>Filme</td> <td><input name="filme" type="text" id="filme" size="50"></td> </tr> </table> </body> </html>
  20. Tenko

    função toXml()

    function toXml() { return "<?xml version='1.0' encoding='iso-8859-1'?> <cachorro> <nome>Tenko</nome> <idade>25</idade> <raca>Raça???</raca> </cachorro>"; }
  21. Tenko

    Manejo de consulta

    Bom dia. Vê se seria isso que você quer $iMaximoPorLinha = 50; $iTotalReg = 210; $sHtml = "<table border='1' width='100%'>"; $sHtml .= '<tr>'; for($i = 1; $i <= $iTotalReg; $i ++) { if ($i % $iMaximoPorLinha == 0) { $sHtml .= "<td>{$i}</td>"; $sHtml .= '</tr>'; } else { $sHtml .= "<td>{$i}</td>"; } } $sHtml .= '</table>'; echo $sHtml;
  22. <!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=iso-8859-1"> <title>teste</title> <script> function valida(){ var controle = 0; var elementos = document.getElementsByName('var[]'); for(var i = 0; i < elementos.length; i++){ if( elementos.checked ) controle++; } if( controle == 0 ) alert('Selecione pelo menos um'); else alert('OK'); } </script> </head> <body> <table width="100%" border="1"> <tr> <td><input type="checkbox" name="var[]" value="1"></td> <td>1</td> </tr> <tr> <td><input type="checkbox" name="var[]" value="2"></td> <td>2</td> </tr> <tr> <td><input type="checkbox" name="var[]" value="3"></td> <td>3</td> </tr> <tr> <td width="4%"> <input type="checkbox" name="var[]" value="4"></td> <td width="96%">4</td> </tr> </table> <br/> <br/> <input type="button" name="Button" value="Gravar" onClick="valida()"> </body> </html>
  23. Tenko

    Duvida conexao com mysql

    O php só vai executar o que estiver sendo enviado pelo FORM, sendo assim se você tiver por exemplo: <form action='php1.php'> ... campos botao submit </form> <form action='php2.php'> ... campos botao submit </form> Ele vai receber os valores do formulário em que você clicou o botão submit
  24. Boa tarde. Fiz este modelo, não é bom usar, é só pra você entender como funciona e te ajudar <!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=iso-8859-1"> <title>Calcula Total</title> <script> var d = document; function $(bloco){ return document.getElementById(bloco); } // Não é o melhor modo, mas fiz simples para você entender function calcula(oObj){ // separando para pegar a chave var aDados = oObj.id.split('_'); var iChave = aDados[1]; var iQtde = $('txtQtd_' + iChave ).value; var fUnit = $('txtUnit_' + iChave ).value; // Não estou fazendo validação nenhuma, só mesmo mostrando um modo de resolver seu problema $('txtTotalLinha_' + iChave ).value = parseFloat( (iQtde * fUnit) ); // chamo a função que faz o calculo do total totalGeral(); } function totalGeral(){ var iTotQtde = 0; var fTotalPedido = 0.00; var oElementosTotal = d.getElementsByName('txtTotalLinha[]'); var oElementosQtde = d.getElementsByName('txtQtd[]'); for( var i = 0; i < oElementosTotal.length; i++){ if( oElementosTotal[i].value != '' ) { iTotQtde += parseFloat( oElementosQtde[i].value ); fTotalPedido += parseFloat( oElementosTotal[i].value ); } } $('totQtde').innerHTML = iTotQtde; $('totTotal').innerHTML = fTotalPedido; } </script> </head> <body> <table width="100%" border="1"> <tr> <td><div align="center">Descri&ccedil;&atilde;o</div></td> <td width="10%"><div align="center">Qtde</div></td> <td width="10%"><div align="center">Unit&aacute;rio</div></td> <td width="10%"><div align="center">Total</div></td> </tr> <tr> <td><div align="left">aaaaa</div></td> <td align="center" valign="middle"><input name="txtQtd[]" type="text" id="txtQtd_1" size="5" maxlength="5" onChange="calcula(this);"></td> <td align="center" valign="middle"><input name="txtUnit[]" type="text" id="txtUnit_1" size="10" maxlength="10" value="10.25"></td> <td align="center" valign="middle"><input name="txtTotalLinha[]" type="text" id="txtTotalLinha_1" size="10" maxlength="10"></td> </tr> <tr> <td><div align="left">bbbbb</div></td> <td align="center" valign="middle"><input name="txtQtd[]" type="text" id="txtQtd_2" size="5" maxlength="5" onChange="calcula(this);"></td> <td align="center" valign="middle"><input name="txtUnit[]" type="text" id="txtUnit_2" size="10" maxlength="10" value="12.25"></td> <td align="center" valign="middle"><input name="txtTotalLinha[]" type="text" id="txtTotalLinha_2" size="10" maxlength="10"></td> </tr> <tr> <td><div align="left">ccccc</div></td> <td align="center" valign="middle"><input name="txtQtd[]" type="text" id="txtQtd_3" size="5" maxlength="5" onChange="calcula(this);"></td> <td align="center" valign="middle"><input name="txtUnit[]" type="text" id="txtUnit_3" size="10" maxlength="10" value="15.25"></td> <td align="center" valign="middle"><input name="txtTotalLinha[]" type="text" id="txtTotalLinha_3" size="10" maxlength="10"></td> </tr> <tr> <td align="right">Total</td> <td align="center"><span id="totQtde"></span></td> <td align="center"></td> <td align="right">R$ <span id="totTotal"></span></td> </tr> </table> </body> </html>
×
×
  • Criar Novo...