Ir para conteúdo
Fórum Script Brasil

Ted k'

Membros
  • Total de itens

    252
  • Registro em

  • Última visita

Posts postados por Ted k'

  1. Script fácil para comparar datas com JavaScript!

    <script language="javascript">
    function checarDatas(){
        var NomeForm = document.Formulario;
    
        var data_1 = NomeForm.data_01.value;
        var data_2 = NomeForm.data_02.value;
        var Compara01 = parseInt(data_1.split("/")[2].toString() + data_1.split("/")[1].toString() + data_1.split("/")[0].toString());
        var Compara02 = parseInt(data_2.split("/")[2].toString() + data_2.split("/")[1].toString() + data_2.split("/")[0].toString());
    
        if (Compara01 > Compara02) {
            document.getElementById("resultado").innerHTML = "Data do Campo 01 Maior";
        }
        else {
              document.getElementById("resultado").innerHTML = "Data do Campo 01 Menor";
        }
        return false;
    }
    </script>
    <div id="resultado"></div>
    <form method="post" action="Teste.pl" name="Formulario" onsubmit="return checarDatas()">
        campo01: <input type="text" id="data_01" /><br />
        campo02: <input type="text" id="data_02" />
    <input type="submit" />
    </form>

  2. Script simples em JavaScript usando jQuery para fazer efeito de fade em títulos de notícias, veja o exemplo no meu blog:

    http://tedk.com.br/blog/index.php/2008/11/...fade-em-jquery/

    Para esse efeito usei um arquivo chamado “mask_news.js”, nele contem todas as informações necessárias para o desenvolvimento do script.

    Abrindo esse arquivo você perceberá uma linha para dar tempo ao efeito, constando em segundos:

    delay = delay || 3000;
    Coloquei 3 segundos, mais fica a seu critério aumentar ou diminuir: Veja o código completo:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Ajax Título News</title>
    <div style="background: #FF9933;">
    <style type="text/css">
        #noticias {
            list-style: none;
            font: 12px Arial;
            font-weight: bold;
        }
    </style>
    
    <script language="javascript" src="jquery-1.2.6.js"></script>
    <script language="javascript" src="mask_news.js"></script>
    
    <script type="text/javascript">
        $(document).ready(
            function() {
                $("#noticias").newsTicker();
                parseSamples();
            }
        );
    </script>
    </head>
    <body>
    <ul id="noticias" style="">
      <li>Campanha incentiva registro civil</li>
      <li>Carga de petróleo está avaliada em US$ 100 milhões.</li>
      <li>Alongamento previne lesões na 'corrida'</li>
      <li>Obama disputa com Lula preferência no Rio</li>
    </ul>
    </body>
    </html>

    Segue abaixo os arquivos para download:

    Baixar: jquery-1.2.6.js

    Baixar: mask_news.js

  3. Carregamento simples de uma página dentro de uma DIV usando AJAX

    Primeiro criamos o arquivo onde fazemos a solicitação do browser, para saber se o navegador suporta ou não “Msxml2.XMLHTTP”

    ajax.js

    function GetXMLHttp() {
        if(navigator.appName == "Microsoft Internet Explorer") {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else {
            xmlHttp = new XMLHttpRequest();
        }
        return xmlHttp;
    }
    
    var xmlRequest = GetXMLHttp();
    No arquivo “instrucao.js” terá as informações necessárias para fazer a ação instrucao.js
    function abrirPag(valor){
        var url = valor;
    
        xmlRequest.open("GET",url,true);    
        xmlRequest.onreadystatechange = mudancaEstado;
        xmlRequest.send(null);
    
            if (xmlRequest.readyState == 1) {
                document.getElementById("conteudo_mostrar").innerHTML = "<img src='loader.gif'>";
            }
    
        return url;
    }
    
    function mudancaEstado(){
        if (xmlRequest.readyState == 4){
            document.getElementById("conteudo_mostrar").innerHTML = xmlRequest.responseText;
        }
    }
    Criamos a página Index.html para recerber as informações Index.html
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Carregando Página em DIV / AJAX</title>
    <script language="javascript" src="ajax.js"></script>
    <script language="javascript" src="instrucao.js"></script>
    </head>
    <body>
        <div id="menu"><a href="#" onclick="abrirPag('Conteudo.html');">Clientes</a></div>
            <br><br>
        <div id="conteudo_mostrar"></div>
    </body>
    </html>
    E finalmente criamos a página Conteudo.html que será exibida dentro da DIV “conteudo_mostrar” Conteudo.html
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Clientes</title>
    </head>
    <body>
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </body>
    </html>

    Qualquer dúvida postem!!

    Abraços!!!!

  4. JSON (JavaScript Object Notation) é um acrônimo que serve como alternativa para XML em AJAX, mais não requer o uso exclusivo de JavaScript.

    O JSON tem várias vantagens sobre o XML, um deles é a facilidade de escreve e o uso da função eval(), isso foi fundamental para o uso dele no AJAX pelo fato de todos os navegadores web aceitarem.

    Existe várias linguagens utilizando o JSON com pacotes de terceiros. Algumas dessas linguagens suportam já o JSON como: JavaScript, ASP, ActionScript, C/C++, C#, Delphi, ColdFusion, Java, Perl, PHP, Python, Rebol e Ruby.

    O Google e a Yahoo são uma das empresas que já usam o JSON em suas aplicações, mais lembrando que o JSON não oferece suporte para referências de objetos.

    Vamos ver agora um exemplo de terceiros com ASP baseado no exemplo do Google para aplicações JSON.

    <!--#Include File="JSON_2.0.2.asp"-->
    <%
    Dim user
    Set user = jsObject()
    
        user("name") = "Ted"
        user("surname") = "SobreNome k"
        user("message") = "Enviando uma Mensagem para JSON"
    
    user.Flush
    %>

    O Resultado é:

    {"name":"Ted","surname":"SobreNome k","message":"Enviando uma Mensagem para JSON"}

    baixe o arquivo JSON_2.0.2.asp

    Super simples, até a próxima!

  5. em primeira mão transforme os quais você quer em type="button" e aplique isso:

    <script language="javascript">
    function clickButton01() {
        location.href = "teste01.aspx";
    }
    
    function clickButton02() {
        location.href = "teste02.aspx";
    }
    </script>
    <input type="button" id="botao01" value="botão 01" onclick="clickButton01();" />
    <input type="button" id="botao01" value="botão 02" onclick="clickButton02();" />

  6. não foi esse que te passei

    olha aqui como tem que estar, faça exatamente como eu coloquei abaixo

    arquivo: script.js

    function meses(){
        var campo = document.getElementById("cad_dt_nmes");
        var mes = new Array("Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Desembro");
    
        for(i=0; i < 11; i++){
            campo.options[i] = new Option(mes[i],"");
        }
    
    }
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <head>
    <title>Pagina de cadastro -Versão 0.1 by Marcio</title>
    <script language="javascript" SRC="script.js"></script>
    <link rel="stylesheet" type="text/css" href="css.css">
    
    </head >
    
    <body>
    <center>
    <table width="800"><tr><td>
    <div class="menu">
    <ul>
    <li><a href="#">Home</a></li>
    <li><a href="#">Cadastro</a></li>
    <li><a href="#">About</a></li>
    </ul>
    </div>
    <div class="corpo">
    <form name="cad" action="cadastro.html" method="post">
    <table border=0><tr>
    <td>Nome:&nbsp</td>
    <td><input type="text" name="cad_nome"><br></td>
    </tr><tr>
    <td>Data de nasciemnto:</td>
    <td><input type="text" name="cad_dt_nasc"><br></td>
    </tr><tr>
    <td>Email / MSN:</td>
    <td><input type="text" name="cad_email"><br></td>
    </tr><tr>
    <td>Data de nasciemnto:</td>
    <td><input type="text" name="cad_dt_ndia">&nbsp<select name="cad_dt_nmes" onfocus="meses();">
    <option value="">Mes</option>
    </select>
    
    <br></td>
    
    </tr><tr>
    <td>Login:</td>
    <td><input type="text" name="cad_login"><br></td>
    </tr><tr>
    <td>Senha:</td>
    <td><input type="password" name="cad_pwd"><br></td>
    </table>
    <input type="submit" value="Enviar">&nbsp<input type="reset" value="Limpar">
    </form>    
    
    </div>
    
    <div class="menu">
    <ul>
    <li>Para saber mais sobre a pagina e quem produziu va em About.</li>
    </ul>
    </td</tr></table>
    </div>
    </center>
    </body>
    </html>

  7. Tenta assim:

    <script language="javascript">
    function meses(){
        var campo = document.getElementById("cad_dt_nmes");
        var mes = new Array("Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Desembro");
    
        for(i=0; i < 11; i++){
            campo.options[i] = new Option(mes[i],"");
        }
    
    }
    </script>
    
    <select name="cad_dt_nmes" onfocus="meses();">
    <option value="">Mes</option>
    </select>

  8. se são três campos faça isso:

    <script language="javascript">
    function resetForm(){
        with (document) {
            getElementById("campo01").value = "";
            getElementById("campo02").value = "";
            getElementById("campo03").value = "";
        }
    }
    </script>
    
    <form id="Form1">
    campo 1: <input type="text" id="campo01" />
    </form>
    <br />
    <form id="Form2">
    campo 2: <input type="text" id="campo02" />
    </form>
    <br />
    <form id="Form3">
    campo 3: <input type="text" id="campo03" />
    </form>
    <br />
    <br />
    <input type="button" value="Limpar Campos" onClick="resetForm();" />

×
×
  • Criar Novo...