<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sylverio &#187; JavaScript</title>
	<atom:link href="http://sylverio.com.br/blog/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://sylverio.com.br/blog</link>
	<description>Análise, Arquitetura, Orientação a Objetos, UML, Tecnologias e Programação</description>
	<lastBuildDate>Mon, 06 Feb 2012 11:01:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Validação de formulário com JQuery</title>
		<link>http://sylverio.com.br/blog/2009/10/validacao-de-formulario-com-jquery/</link>
		<comments>http://sylverio.com.br/blog/2009/10/validacao-de-formulario-com-jquery/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 00:46:07 +0000</pubDate>
		<dc:creator>Carlos Fernando Sylverio</dc:creator>
				<category><![CDATA[Programação]]></category>
		<category><![CDATA[Tecnologia]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://sylverio.com.br/blog/?p=286</guid>
		<description><![CDATA[Validation é um plugin do framework jQuery que permite fazer a validação de formulários de várias maneiras. Neste post vou demonstrar como realizar algumas validações em um formulário utilizando o este plugin. Para é necessário fazer o download do jQuery &#8230;<p class="read-more"><a href="http://sylverio.com.br/blog/2009/10/validacao-de-formulario-com-jquery/">Saiba mais &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>Validation</strong> é um plugin do <a href="http://sylverio.com.br/blog/?p=57">framework jQuery</a> que permite fazer a validação de formulários de várias maneiras.<br />
Neste post vou demonstrar como realizar algumas validações em um formulário utilizando o este plugin. </p>
<p>Para é necessário fazer o download do <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" target="_blanck">jQuery plugin: Validation</a></p>
<p>Pronto agora que temos todos os arquivos necessário, devemos incluir na tag <head> de nosso exemplo o seguinte trecho de código:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script language<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;JavaScript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;jquery/jquery-1.3.2.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script language<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;JavaScript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;jquery-validate/jquery.validate.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Ainda dentro da tag head, inserimos o trecho de código que fará a validação de nosso formulário:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#cadastro&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">validate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// Define as regras</span>
        rules<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
            nomeCliente<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
                required<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> 
                minlength<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span>
             <span style="color: #009900;">&#125;</span>
         <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
         <span style="color: #006600; font-style: italic;">// Define as mensagens de erro para cada regra</span>
         messages<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
              nomeCliente<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
                  required<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Digite o seu nome.&quot;</span><span style="color: #339933;">,</span>
                  minLength<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;O seu nome deve conter, no mínimo, 2 caracteres.&quot;</span>
              <span style="color: #009900;">&#125;</span>
          <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Agora é só inserir o código HTML do formulário a página:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;form id=&quot;cadastro&quot; method=&quot;post&quot; action=&quot;&quot;&gt;
    &lt;p&gt;&lt;label&gt;Nome:&lt;/label&gt;&lt;input type=&quot;text&quot; id=&quot;nome_cliente&quot; name=&quot;nomeCliente&quot; /&gt;&lt;/p&gt;
     &lt;input type=&quot;submit&quot; value=&quot;Enviar&quot; /&gt;
&lt;/form&gt;</pre></div></div>

<p>Observe que as regras e mensagens aplicadas a caixa de texto são referênciadas pelo nome do elemento (atributo name) e não pelo id.</p>
<p>Dessa forma, podemos fazer validações de formulário, de uma forma simples e rápida. Mais informações e métodos de valições podem ser entrados na <a href="http://docs.jquery.com/Plugins/Validation" target="_blanck">documentação oficial do JQuery</a>.</p>
<p>Para quem conhece <strong>css</strong>, o código gerado ao apresentar a mensagem contem o atributo <em>class</em> com o valor <em>error</em>, que pode ser usado para aprimorar o layout do formulário.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;form id=&quot;cadastro&quot; action=&quot;&quot; method=&quot;post&quot;&gt;
    &lt;p&gt;&lt;label&gt;Nome:&lt;/label&gt;&lt;input id=&quot;nome_cliente&quot; class=&quot;error&quot; type=&quot;text&quot; name=&quot;nomeCliente&quot;/&gt;
            &lt;label class=&quot;error&quot; for=&quot;nome_cliente&quot; generated=&quot;true&quot;&gt;O seu nome deve conter, no mínimo, 2 caracteres.&lt;/label&gt;
     &lt;/p&gt;
     &lt;input class=&quot;submit&quot; type=&quot;submit&quot; value=&quot;Enviar&quot;/&gt;
&lt;/form&gt;</pre></div></div>

<p>Enjoy <img src='http://sylverio.com.br/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://sylverio.com.br/blog/2009/10/validacao-de-formulario-com-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Introdução ao Ajax</title>
		<link>http://sylverio.com.br/blog/2009/10/introducao-ao-ajax/</link>
		<comments>http://sylverio.com.br/blog/2009/10/introducao-ao-ajax/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 01:13:58 +0000</pubDate>
		<dc:creator>Carlos Fernando Sylverio</dc:creator>
				<category><![CDATA[Programação]]></category>
		<category><![CDATA[Tecnologia]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://sylverio.com.br/blog/?p=254</guid>
		<description><![CDATA[O problema que o Ajax tenta resolver está enraizado no protocolo de comunicação HTTP. Isso porque esse protocolo é sem estado (stateless), assim o controle das ações executadas na aplicação cliente é controlado pelo código no servidor web. Ou seja, &#8230;<p class="read-more"><a href="http://sylverio.com.br/blog/2009/10/introducao-ao-ajax/">Saiba mais &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>O problema que o Ajax tenta resolver está enraizado no protocolo de comunicação HTTP. Isso porque esse protocolo é sem estado (stateless), assim o controle das ações executadas na aplicação cliente é controlado pelo código no servidor web. Ou seja, as alterações (ou entrada de dados) executadas na página web pelo usuário são enviadas para o servidor para que este atualize seu estado, e o servidor responde a alteração reenviado todo o HTML para o browser.</p>
<p><img style="float:right" src="image/Ajax_TriplaAcao.png" alt="Ajax"><br />
<strong>Mas o que é o Ajax?</strong></p>
<p>Ajax é o acrônimo (da língua inglesa) de <em>Asynchronous Javascript and XML</em>, ele não é uma linguagem de programação e sim a combinação de tecnologias existentes (<em>Javascript</em>, <em>XML</em> e <em>XmlHttpRequest</em>) que nos permite realizar solicitações assíncronas ao servidor para busca de informações e/ou atualizar seu estado.<br />
Em outras palavras o Ajax, é um objeto presente nos browser atuais que combinado com JavaScript pode se comunicar com o servidor Web sem recarregar e redesenhar a página inteira.</p>
<p><strong>Utilizando do Ajax</strong></p>
<p>O exemplo abaixo apresenta uma página chamada calcProduto.html, onde o usuário escolhe o tipo de produto e informa a quantidade de  produto que gostaria de adquir. Ao clicar no botão calcular, é realizado via ajax uma requisição ao servidor web (arquivo calcProduto.php) que realiza o calculo necessário e sua reposta é renderizada sem recarregar a página html.</p>
<p>Abaixo o código do arquivo calcProduto.html:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>html<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>head<span style="color: #339933;">&gt;</span>
        <span style="color: #339933;">&lt;</span>title<span style="color: #339933;">&gt;</span>Produto<span style="color: #339933;">&lt;/</span>title<span style="color: #339933;">&gt;</span>
        <span style="color: #339933;">&lt;</span>script language<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;javascript&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
            <span style="color: #003366; font-weight: bold;">var</span> request <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// função que cria objeto de requisição</span>
            <span style="color: #003366; font-weight: bold;">function</span> createRequest <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #006600; font-style: italic;">// cria objeto XmlHttpRequest para os browser Firefox, Safari, Opera</span>
                    request <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span> trymicrosoft <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #006600; font-style: italic;">// cria objeto XmlHttpRequest para o browser IE</span>
                        request <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;Msxm12.XMLHTTP&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span> othermicrosoft <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #000066; font-weight: bold;">try</span><span style="color: #009900;">&#123;</span>
                            <span style="color: #006600; font-style: italic;">// cria objeto XmlHttpRequest para o browser IE</span>
                            request <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;Microsoft.XMLHTTP&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span> failed <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                            request <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
                        <span style="color: #009900;">&#125;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> request <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;Erro ao criar objeto Request!&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// função que executa chamada ao servidor para realizar o calculo</span>
            <span style="color: #003366; font-weight: bold;">function</span> getPrice <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
                createRequest <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #003366; font-weight: bold;">var</span> prod <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;produto&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
                <span style="color: #003366; font-weight: bold;">var</span> qtd <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;quantidade&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
                <span style="color: #003366; font-weight: bold;">var</span> url <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;calcProduto.php?produto=&quot;</span> <span style="color: #339933;">+</span> prod <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;&amp;quantidade=&quot;</span> <span style="color: #339933;">+</span> qtd<span style="color: #339933;">;</span>
&nbsp;
                request.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;GET&quot;</span><span style="color: #339933;">,</span> url<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                request.<span style="color: #660066;">onreadystatechange</span> <span style="color: #339933;">=</span> updatePage<span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// define função a ser chamada a obter resposta do servidor web</span>
                request.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// null informa que não está sendo enviado nenhum dado na requisição</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// função chamada ao obter retorno da requisição e atualiza interface</span>
            <span style="color: #003366; font-weight: bold;">function</span> updatePage <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
                <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> request.<span style="color: #660066;">readyState</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">4</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> request.<span style="color: #000066;">status</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">200</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                        <span style="color: #003366; font-weight: bold;">var</span> resultado <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;resultado&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        resultado.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> request.<span style="color: #660066;">responseText</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                    <span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
                        <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;Erro: não foi possível obter resposta do servidor.&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;/</span>head<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>body<span style="color: #339933;">&gt;</span>
        <span style="color: #339933;">&lt;</span>h1<span style="color: #339933;">&gt;</span>Calculo de produto<span style="color: #339933;">&lt;/</span>h1<span style="color: #339933;">&gt;</span>
        <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span> Escolha um produto e informe a quantidade.<span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
        <span style="color: #339933;">&lt;</span>form method<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;GET&quot;</span> action<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;calcProduto.php&quot;</span><span style="color: #339933;">&gt;</span>
            <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span> Produto<span style="color: #339933;">:</span> 
                <span style="color: #339933;">&lt;</span>select <span style="color: #000066;">name</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;produto&quot;</span> id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;produto&quot;</span><span style="color: #339933;">&gt;</span>
                    <span style="color: #339933;">&lt;</span>option value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;0&quot;</span><span style="color: #339933;">&gt;</span>Caneta<span style="color: #339933;">&lt;/</span>option<span style="color: #339933;">&gt;</span>
                    <span style="color: #339933;">&lt;</span>option value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;1&quot;</span><span style="color: #339933;">&gt;</span>Borracha<span style="color: #339933;">&lt;/</span>option<span style="color: #339933;">&gt;</span>
                    <span style="color: #339933;">&lt;</span>option value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;2&quot;</span><span style="color: #339933;">&gt;</span>Giz<span style="color: #339933;">&lt;/</span>option<span style="color: #339933;">&gt;</span>
                    <span style="color: #339933;">&lt;</span>option value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;3&quot;</span><span style="color: #339933;">&gt;</span>Apagador<span style="color: #339933;">&lt;/</span>option<span style="color: #339933;">&gt;</span>
                <span style="color: #339933;">&lt;/</span>select<span style="color: #339933;">&gt;</span>
            <span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>htm
            <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span> Quantidade <span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;quantidade&quot;</span> id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;quantidade&quot;</span><span style="color: #339933;">&gt;&lt;/</span>p<span style="color: #339933;">&gt;</span>
            <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;button&quot;</span> value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;Calcular&quot;</span> onClick<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;getPrice();&quot;</span><span style="color: #339933;">&gt;&lt;/</span>p<span style="color: #339933;">&gt;</span>
        <span style="color: #339933;">&lt;/</span>form<span style="color: #339933;">&gt;</span>
        <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;resultado&quot;</span><span style="color: #339933;">&gt;</span>
        <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;/</span>body<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>html<span style="color: #339933;">&gt;</span></pre></div></div>

<p>O código utilizado no servidor web:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #000088;">$produto</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'produto'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$qtd</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'quantidade'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$prodName</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$vlr</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$produto</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;0&quot;</span><span style="color: #339933;">:</span>
            <span style="color: #000088;">$prodName</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Caneta'</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$vlr</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'1'</span><span style="color: #339933;">:</span>
            <span style="color: #000088;">$prodName</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Borracha'</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$vlr</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'2'</span><span style="color: #339933;">:</span>
            <span style="color: #000088;">$prodName</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Giz'</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$vlr</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'3'</span><span style="color: #339933;">:</span>
            <span style="color: #000088;">$prodName</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Apagador'</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$vlr</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000088;">$total</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$qtd</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$vlr</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;h3&gt;Calculo:&lt;/h3&gt;
&lt;table  border=1 &gt;
    &lt;tr&gt;
        &lt;td&gt;Produto&lt;/td&gt;
        &lt;td&gt;Quantida&lt;/td&gt;
        &lt;td&gt;Valor unidade&lt;/td&gt;
        &lt;td&gt;Total&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">print</span> <span style="color: #000088;">$prodName</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
        &lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">print</span> <span style="color: #000088;">$qtd</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
        &lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;R$ &quot;</span> <span style="color: #339933;">.</span><span style="color: #990000;">number_format</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$vlr</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
        &lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;R$ &quot;</span> <span style="color: #339933;">.</span><span style="color: #990000;">number_format</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$total</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;</pre></div></div>

<p>Futuramente falarei um pouco mais sobre o componente XmlHttpRequest e seus recursos.<br />
Enjoy <img src='http://sylverio.com.br/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://sylverio.com.br/blog/2009/10/introducao-ao-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apresentando o JQuery</title>
		<link>http://sylverio.com.br/blog/2009/02/apresentando-o-jquery/</link>
		<comments>http://sylverio.com.br/blog/2009/02/apresentando-o-jquery/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 02:18:38 +0000</pubDate>
		<dc:creator>Carlos Fernando Sylverio</dc:creator>
				<category><![CDATA[Programação]]></category>
		<category><![CDATA[Tecnologia]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://sylverio.com.br/blog/?p=57</guid>
		<description><![CDATA[Há um bom tempo tudo está convergindo para web, e com isso surgem coisas interessantes, é o caso de uma bibliotéca de JavaScript chamada JQuery. Há um ano mais ou menos quando um amigo meu me apresentou fiquei impressionado com &#8230;<p class="read-more"><a href="http://sylverio.com.br/blog/2009/02/apresentando-o-jquery/">Saiba mais &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Há um bom tempo tudo está convergindo para web, e com isso surgem coisas interessantes, é o caso de uma bibliotéca de JavaScript chamada <a href="http://jquery.com/" target="_blank">JQuery</a>. </p>
<p>Há um ano mais ou menos quando um amigo meu me apresentou fiquei impressionado com a facilidade de codificação, efeitos visuais e possibilidades de uso que essa biblioteca propociona para o desenvolvimento de aplicações Web e continuo me impressionando a cada nova versão.</p>
<p>As principais características do JQuery que se destacam são:</p>
<ul>
<li>Robusto e eficiente mecanismo de acesso a partes da página (DOM).</li>
<li>Modifica a aparência da página.</li>
<li>Alteração do conteúdo da página.</li>
<li>Variedade de eventos para interação com os usuários.</li>
<li>Adição de efeitos visuais as páginas.</li>
<li>Implementação de Ajax de forma fácil.</li>
<li>Simplificação de tarefas comuns em JavaScript.</li>
</ul>
<p></p>
<p>É uma biblioteca estável e já utilizada por diversas corporações. Em sua página Web é possível acessar sua documentação, especificações, plugins de interface, de forma muito estruturada.</p>
<p>Futuramente falerei mais sobre essa biblioteca e criarei alguns exemplos de sua utilização.</p>
<p>Até mais <img src='http://sylverio.com.br/blog/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://sylverio.com.br/blog/2009/02/apresentando-o-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

