<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.5" -->
<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/"
	>

<channel>
	<title>Silici0 :: Blog</title>
	<link>http://www.rafaelcunha.com</link>
	<description>Php, JS, JQuery, Ajax e +++</description>
	<pubDate>Thu, 08 May 2008 13:32:54 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.5</generator>
	<language>en</language>
			<item>
		<title>Orientação a Objetos php4 parte 2</title>
		<link>http://www.rafaelcunha.com/2008/04/17/orientacao-a-objetos-php4-parte-2/</link>
		<comments>http://www.rafaelcunha.com/2008/04/17/orientacao-a-objetos-php4-parte-2/#comments</comments>
		<pubDate>Thu, 17 Apr 2008 13:53:23 +0000</pubDate>
		<dc:creator>silici0</dc:creator>
		
		<category>Informatica</category>

		<category>php</category>

		<category>Tutorial</category>

		<guid isPermaLink="false">http://www.rafaelcunha.com/2008/04/17/orientacao-a-objetos-php4-parte-2/</guid>
		<description><![CDATA[Bom, já sabemos como definir e estarciarmos uma Classe, correto ? Se você ainda não sabe da uma olhada na parte 1, se você já sabe, bom, continuaremos hoje
mostrando como usar essa classe instanciada, como chamar seu método e definir variaveis.
Para nós utilizarmos um método (função) de uma classe faremos o seguinte, primeiro definimos ela:
PLAIN [...]]]></description>
			<content:encoded><![CDATA[<p>Bom, já sabemos como definir e estarciarmos uma Classe, correto ? Se você ainda não sabe da uma olhada na <a title="OO php4" target="_blank" href="http://www.rafaelcunha.com/2008/04/01/orientacao-a-objetos-oo-php4/">parte 1</a>, se você já sabe, bom, continuaremos hoje</p>
<p>mostrando como usar essa classe instanciada, como chamar seu método e definir variaveis.</p>
<p>Para nós utilizarmos um método (função) de uma classe faremos o seguinte, primeiro definimos ela:</p>
<div class="igBar"><span id="lphp-5"><a href="#" onclick="javascript:showCodeTxt('php-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-5">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">Class</span> MinhaClasse<span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$atributo1</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$atributo2</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> metodo<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#0000FF;">$atributo1</span> = <span style="color:#FF0000;">"Ola, Mundo!"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$atributo1</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Instaciamos ela:</p>
<div class="igBar"><span id="lphp-6"><a href="#" onclick="javascript:showCodeTxt('php-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-6">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$Obj</span> = <span style="color:#000000; font-weight:bold;">new</span> MinhaClasse<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Então agora chamaremos (executaremos) o método metodo() do nosso objeto OBJ:</p>
<div class="igBar"><span id="lphp-7"><a href="#" onclick="javascript:showCodeTxt('php-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-7">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$Obj</span>-&gt;<span style="color:#006600;">metodo</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>veja o resultado e se divirta. Perceba que a chamada de um método é sempre $Obj->nome_do_método($variaveis);, no caso para atribuirmos valores a um atributo (variavél) dentro da nossa Classe utilizamos $this-> que é uma pseudo-variável que quer dizer 'eu' ou 'objeto atual' fazendo referência a o Objeto que ela está, outro exemplo da $this->.</p>
<div class="igBar"><span id="lphp-8"><a href="#" onclick="javascript:showCodeTxt('php-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-8">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">Class</span> MinhaClasse<span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$atributo1</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$atributo2</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> metodo<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">atributo1</span> = <span style="color:#FF0000;">"Ola, Mundo!"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Chamarei um outro método dentro deste método;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">metodo2</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$atributo1</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> metodo2<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">atributo1</span> = <span style="color:#FF0000;">"Ola, Mundo Seja bem vindo a classe MinhaClasse!"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Acho que por hoje é só... Apartir disso ja da para começar a escrever funções em classes.
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rafaelcunha.com/2008/04/17/orientacao-a-objetos-php4-parte-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Orientação a Objetos (OO) php4</title>
		<link>http://www.rafaelcunha.com/2008/04/01/orientacao-a-objetos-oo-php4/</link>
		<comments>http://www.rafaelcunha.com/2008/04/01/orientacao-a-objetos-oo-php4/#comments</comments>
		<pubDate>Tue, 01 Apr 2008 16:52:01 +0000</pubDate>
		<dc:creator>silici0</dc:creator>
		
		<category>Informatica</category>

		<category>php</category>

		<category>Tutorial</category>

		<guid isPermaLink="false">http://www.rafaelcunha.com/2008/04/01/orientacao-a-objetos-oo-php4/</guid>
		<description><![CDATA[Estou presumindo que você pelo menos tenha os conceitos básicos de Orientação a Objetos para entender este tutorial, caso não tenha veja AQUI um pouco sobre, estou escrevendo do php4 para começarmos a aprender, vendo que no php5 é bem diferente, a idéia é que venha outros textos sobre Orientação a Objetos com dicas e [...]]]></description>
			<content:encoded><![CDATA[<p>Estou presumindo que você pelo menos tenha os conceitos básicos de Orientação a Objetos para entender este tutorial, caso não tenha veja <a target="_blank" title="Blog Etilico - Teoria em OO " href="http://blogetilico.wordpress.com/2007/03/30/introducao-a-orientacao-a-objetos-primeira-parte/">AQUI </a>um pouco sobre, estou escrevendo do php4 para começarmos a aprender, vendo que no php5 é bem diferente, a idéia é que venha outros textos sobre Orientação a Objetos com dicas e boas práticas na hora de codar.</p>
<p>Porque utilizar Objetos</p>
<p>Pois objetos são facilmente reutilizados nos códigos, você irá aumentar a Flexibilidade na hora de programar e aumentar a velocidade na manutenção dos seus scripts, terá ainda maior compatibilidade de compartilhar códigos com outros programadores (sejam eles da sua equipe ou amigos).<br />
Maior facilidade para extender o seu código e debugar ele, o que covenhamos as vezes é complicado!</p>
<p>Objetos e Classes</p>
<p>No PHP para ter um objeto nós devemos instacia-lo apartir de uma classe, digamos assim que devemos criar a Classe e depois então instaciar em um Objeto, presumindo que você tenha uma idéia do que é um método (função) e atributos (variáveis).</p>
<p>Para definirmos uma classe temos :</p>
<div class="igBar"><span id="lphp-11"><a href="#" onclick="javascript:showCodeTxt('php-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-11">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> MinhaClasse<span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Atributos</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$atributo1</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$atributo2</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Métodos</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> metodo1<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Código de execução quando o método for chamado</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">return</span> <span style="color:#0000FF;">$algumaCoisa</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> metodo2<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Código de execução quando o método for chamado</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Para instanciarmos nossa Classe em Objeto fazemos :</p>
<div class="igBar"><span id="lphp-12"><a href="#" onclick="javascript:showCodeTxt('php-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-12">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$MeuObjeto</span> = <span style="color:#000000; font-weight:bold;">new</span> MinhaClasse<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Podemos instacia-lo quantas vezes for necessario</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$MeuObjeto1</span> = <span style="color:#000000; font-weight:bold;">new</span> MinhaClasse<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$novoNome</span> = <span style="color:#000000; font-weight:bold;">new</span> MinhaClasse<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rafaelcunha.com/2008/04/01/orientacao-a-objetos-oo-php4/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Do SelectBox para o ListBox</title>
		<link>http://www.rafaelcunha.com/2007/10/01/do-selectbox-para-o-listbox/</link>
		<comments>http://www.rafaelcunha.com/2007/10/01/do-selectbox-para-o-listbox/#comments</comments>
		<pubDate>Mon, 01 Oct 2007 17:21:36 +0000</pubDate>
		<dc:creator>silici0</dc:creator>
		
		<category>Informatica</category>

		<category>php</category>

		<category>JavaScript</category>

		<category>JQuery</category>

		<category>Tutorial</category>

		<guid isPermaLink="false">http://www.rafaelcunha.com/2007/10/01/do-selectbox-para-o-listbox/</guid>
		<description><![CDATA[Tutorialzinho para criarmos um selectbox e um listbox apartir do formulário em html e então através do JQuery adicionarmos os itens no Listbox e então pegarmos o valor por método POST no PHP.
A idéia do tutorial seria uma lista de itens adicionado a um listbox, formando um carrinho de compras dos itens, para depois então [...]]]></description>
			<content:encoded><![CDATA[<p>Tutorialzinho para criarmos um selectbox e um listbox apartir do formulário em html e então através do <a href="http://jquery.com"  class="alinks_links" onclick="return alinks_click(this);" title="JavaScript Framework"  style="padding-right: 13px; background: url(http://rafaelcunha.com/WordPress/wp-content/plugins/alinks/images/external.png) center right no-repeat;" rel="external">JQuery</a> adicionarmos os itens no Listbox e então pegarmos o valor por método POST no PHP.</p>
<p>A idéia do tutorial seria uma lista de itens adicionado a um listbox, formando um carrinho de compras dos itens, para depois então enviarmos tudo de uma vez so através do POST do form, gerando uma array para o PHP, é um dos clássicos em programação. Como muita gente não sabe da possibilidade em html/php deixo um tutorial para se ter uma idéia de como utilizar esse recurso.<br />
Sem mais delongas vamos ao código, primeiramente o form, claramente veremos que o nosso listbox na verdade é um selectbox com a tag de multiple (virando assim um listbox):</p>
<div class="igBar"><span id="lhtml-15"><a href="#" onclick="javascript:showCodeTxt('html-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-15">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/form.html"><span style="color: #000000; font-weight: bold;">&lt;form</span></a> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">"post"</span> <span style="color: #000066;">enctype</span>=<span style="color: #ff0000;">"multipart/form-data"</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"F1"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"F1"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/select.html"><span style="color: #000000; font-weight: bold;">&lt;select</span></a> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"func"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"func"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/option.html"><span style="color: #000000; font-weight: bold;">&lt;option</span></a> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"1"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>Numero 1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/option&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/option.html"><span style="color: #000000; font-weight: bold;">&lt;option</span></a> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"2"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>Numero 2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/option&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/option.html"><span style="color: #000000; font-weight: bold;">&lt;option</span></a> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"3"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>Numero 3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/option&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/select&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"button"</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"add"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"Adicionar"</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/select.html"><span style="color: #000000; font-weight: bold;">&lt;select</span></a> <span style="color: #000066;">multiple</span>=<span style="color: #ff0000;">"multiple"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"eq"</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"eq[]"</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">"7"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/select&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">&lt;input</span></a> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"Submit2"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"submit"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"EnvioDados"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"ENVIAR DADOS"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/form&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Agora podemos escrever o código do JQuery com <a href="http://pt.wikipedia.org/wiki/DOM"  class="alinks_links" onclick="return alinks_click(this);" title="Document Object Model"  style="padding-right: 13px; background: url(http://rafaelcunha.com/WordPress/wp-content/plugins/alinks/images/external.png) center right no-repeat;" rel="external">DOM</a> para facilitar nossa vida:</p>
<div class="igBar"><span id="ljavascript-16"><a href="#" onclick="javascript:showCodeTxt('javascript-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-16">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">ready</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//Click do botão ADD</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"input[@name=add]"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">click</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> id_selecionado = document.<span style="color: #006600;">F1</span>.<span style="color: #006600;">func</span>.<span style="color: #006600;">selectedIndex</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> valor_selecionado = document.<span style="color: #006600;">F1</span>.<span style="color: #006600;">func</span>.<span style="color: #006600;">options</span><span style="color: #66cc66;">&#91;</span>id_selecionado<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">text</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> id_indice_selecionado = document.<span style="color: #006600;">F1</span>.<span style="color: #006600;">func</span>.<span style="color: #006600;">options</span><span style="color: #66cc66;">&#91;</span>id_selecionado<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">value</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'select[@id=eq]'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">append</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'&lt;option value=&quot;'</span>+ id_indice_selecionado +<span style="color: #3366CC;">'&quot;&gt;'</span>+ valor_selecionado +<span style="color: #3366CC;">'&lt;/option&gt;'</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//desabilita o valor adicionado;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">document.<span style="color: #006600;">F1</span>.<span style="color: #006600;">func</span>.<span style="color: #006600;">options</span><span style="color: #66cc66;">&#91;</span>id_selecionado<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">disabled</span>=<span style="color: #003366; font-weight: bold;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// Click do botao do submit</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'input[@name=Submit2]'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">click</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> x=document.<span style="color: #006600;">getElementById</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"eq"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span>i=<span style="color: #CC0000;color:#800000;">0</span>;i&lt;x.<span style="color: #006600;">length</span>;i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">x.<span style="color: #006600;">options</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">selected</span>=<span style="color: #003366; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Muito legal né? Mas e para remover ? Bom, para remover eu recomendo dar uma procurada na net sobre um plugin para ListBox usando o JQuery, vocês não querem tudo na mão né? Dúvidas e sugestões é so comentar.
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rafaelcunha.com/2007/10/01/do-selectbox-para-o-listbox/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Album de fotos</title>
		<link>http://www.rafaelcunha.com/2007/09/11/album-de-fotos-2/</link>
		<comments>http://www.rafaelcunha.com/2007/09/11/album-de-fotos-2/#comments</comments>
		<pubDate>Tue, 11 Sep 2007 15:25:20 +0000</pubDate>
		<dc:creator>silici0</dc:creator>
		
		<category>Informatica</category>

		<category>php</category>

		<category>Tutorial</category>

		<guid isPermaLink="false">http://rafaelcunha.com/2007/09/11/album-de-fotos-2/</guid>
		<description><![CDATA[Meu album de fotos, o script foi liberado para uso geral do universo. Leia as informações com calma, respire, compreenda e utilize, seja feliz.   Dúvidas podem ser postadas aqui com toda liberdade, serão todas respondidas aqui.
Basta no menu do topo clicar em Album de fotos para visualizar as informações ou use o link [...]]]></description>
			<content:encoded><![CDATA[<p>Meu album de fotos, o script foi liberado para uso geral do universo. Leia as informações com calma, respire, compreenda e utilize, seja feliz. <img src='http://www.rafaelcunha.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  Dúvidas podem ser postadas aqui com toda liberdade, serão todas respondidas aqui.</p>
<p>Basta no menu do topo clicar em Album de fotos para visualizar as informações ou use o <a target="_blank" href="http://rafaelcunha.com/album-de-fotos/">link aqui</a>.
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rafaelcunha.com/2007/09/11/album-de-fotos-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>CronJobs em PHP no Cpanel</title>
		<link>http://www.rafaelcunha.com/2007/09/04/cronjobs-em-php-no-cpanel/</link>
		<comments>http://www.rafaelcunha.com/2007/09/04/cronjobs-em-php-no-cpanel/#comments</comments>
		<pubDate>Tue, 04 Sep 2007 18:57:43 +0000</pubDate>
		<dc:creator>silici0</dc:creator>
		
		<category>Informatica</category>

		<category>Trabalho</category>

		<category>php</category>

		<category>Linux</category>

		<category>Tutorial</category>

		<guid isPermaLink="false">http://rafaelcunha.com/2007/09/04/cronjobs-em-php-no-cpanel/</guid>
		<description><![CDATA[Como roda scripts em cronjob no Cpanel, pelo menos os em PHP, depois de muita busca e falta de informação pela net achei um modo de como fazer e vou compartilhar com vocês.
Cron é uma agenda no unix que executa comandos, cronjob é o software que faz a execução desses comandos programados, veja mais no [...]]]></description>
			<content:encoded><![CDATA[<p>Como roda scripts em cronjob no Cpanel, pelo menos os em PHP, depois de muita busca e falta de informação pela net achei um modo de como fazer e vou compartilhar com vocês.</p>
<p>Cron é uma agenda no unix que executa comandos, cronjob é o software que faz a execução desses comandos programados, veja mais no Wikipedia sobre <a target="_blank" href="http://pt.wikipedia.org/wiki/Crontab">CronJob</a>. Ja que é muito simples não tem muito mais além disto.</p>
<p>Para então nos executarmos no Cpanel um cron de um arquivo em PHP, vamo em Cron Jobs, depois em Advanced (claro que não somos n00bs, somos haxor e vamos onde tem mais opções), logo colocaremos nosso email para caso de algo errado sejamos informados. O comando a ser executado é o endereço completo onde o arquivo esta localizado no servidor, mais ou menos algo assim <em>/home/usuario/public_html/arquivo.php</em> . Nos quadros anteriores nos colocamos de quanto em quanto tempo desejamos executar, a cada minuto so deixar tudo com *, veja mais no wiki sobre Cron. <img src='http://www.rafaelcunha.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>O mais importante agora para executar o Cronjob do php é na primeira linha do seu PHP colocar o codigo abaixo, mesmo antes da tag de iniciação do PHP:</p>
<div class="igBar"><span id="lphp-18"><a href="#" onclick="javascript:showCodeTxt('php-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-18">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;">#! /usr/bin/php -q</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">include</span> <span style="color:#FF0000;">"configuracao.php"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$query</span>=<span style="color:#FF0000;">"SELECT * FROM func WHERE hora &lt;&gt; '00:00:00'"</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rafaelcunha.com/2007/09/04/cronjobs-em-php-no-cpanel/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JSON Populando formulário</title>
		<link>http://www.rafaelcunha.com/2007/08/28/json-populando-formulario/</link>
		<comments>http://www.rafaelcunha.com/2007/08/28/json-populando-formulario/#comments</comments>
		<pubDate>Tue, 28 Aug 2007 02:25:29 +0000</pubDate>
		<dc:creator>silici0</dc:creator>
		
		<category>Informatica</category>

		<category>JavaScript</category>

		<category>AJAX</category>

		<category>Tutorial</category>

		<guid isPermaLink="false">http://rafaelcunha.com/2007/08/28/json-populando-formulario/</guid>
		<description><![CDATA[JSON, o que é ? É um acrônimo para JavaScript Object Notation, serve para que ? Serve para fazer intercâmbio de dados, mais utilizado no Ajax, atualmente utilizado para retorno de dados para o AJAX, com a necessidade de popular (retornar) dados para um formulário.
JSON que se lê djeissón, pode ser utilizado em diversas linguagens, [...]]]></description>
			<content:encoded><![CDATA[<p>JSON, o que é ? É um acrônimo para JavaScript Object Notation, serve para que ? Serve para fazer intercâmbio de dados, mais utilizado no Ajax, atualmente utilizado para retorno de dados para o AJAX, com a necessidade de popular (retornar) dados para um formulário.</p>
<p>JSON que se lê djeissón, pode ser utilizado em diversas linguagens, como php, c/c++, javascript, Java, Delphi, Perl, Python, Ruby, ColdFusion e muitas outras.</p>
<p>Imaginamos que ao clicar no botão alterar dados de uma lista, queremos trazer os dados da requisição do HTTP (Ajax) para colocalos no formulario. Para isso devemos retornar um dado do Ajax (arquivo da requisição) em JSON.</p>
<p>Para se encapsular dados para o Json no PHP basta o seguinte:</p>
<div class="igBar"><span id="lphp-21"><a href="#" onclick="javascript:showCodeTxt('php-21'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-21">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$array</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'a'</span>=&gt;<span style="color:#CC66CC;color:#800000;">1</span>,<span style="color:#FF0000;">'b'</span> =&gt; <span style="color:#CC66CC;color:#800000;">2</span>, <span style="color:#FF0000;">'c'</span> =&gt; <span style="color:#CC66CC;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$res</span>=json_encode<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$array</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// retornando no res o seguinte:</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// {&quot;a&quot;:1, &quot;b&quot;:2, &quot;c&quot;:3 } </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Otimo, agora como devemos ler os dados do retorno no JavaScript? Essa é parte mais fácil, para converter dados do texto <a href="http://pt.wikipedia.org/wiki/JSON"  class="alinks_links" onclick="return alinks_click(this);" title="JavaScript Object Notation"  style="padding-right: 13px; background: url(http://rafaelcunha.com/WordPress/wp-content/plugins/alinks/images/external.png) center right no-repeat;" rel="external">JSON</a> para objetos (variavel do JS) basta usar a função eval();</p>
<div class="igBar"><span id="ljavascript-22"><a href="#" onclick="javascript:showCodeTxt('javascript-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-22">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// resposta é o $res do PHP, retorno dos dados</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">eval</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"var arr = "</span>+resposta<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// Agora temos uma array de dados em javascript</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// exemplo arr.a = 1</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// exemplo arr.b = 2</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// exemplo arr.c = 3 </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Agora basta popular o formulário (inputs, text area e afins) com <a href="http://pt.wikipedia.org/wiki/DOM"  class="alinks_links" onclick="return alinks_click(this);" title="Document Object Model"  style="padding-right: 13px; background: url(http://rafaelcunha.com/WordPress/wp-content/plugins/alinks/images/external.png) center right no-repeat;" rel="external">DOM</a> HTML. Pronto você aprendeu como JSON trabalha, o que é e como utilizar, agora basta utilizar suas ideias em conjunto ao <a href="http://pt.wikipedia.org/wiki/AJAX_%28programa%C3%A7%C3%A3o%29"  class="alinks_links" onclick="return alinks_click(this);" title="Asynchronous JavaScript and XML"  style="padding-right: 13px; background: url(http://rafaelcunha.com/WordPress/wp-content/plugins/alinks/images/external.png) center right no-repeat;" rel="external">Ajax</a> e construir maravilhas.
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rafaelcunha.com/2007/08/28/json-populando-formulario/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
