<?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>Pau Gay &#187; javascript</title>
	<atom:link href="http://paugay.com/blog/category/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://paugay.com/blog</link>
	<description>eres lo que haces, no lo que dices</description>
	<lastBuildDate>Mon, 14 Nov 2011 00:11:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Iterar sobre array en PHP y Javascript</title>
		<link>http://paugay.com/blog/2010/05/iterar-array-php-javascript.html</link>
		<comments>http://paugay.com/blog/2010/05/iterar-array-php-javascript.html#comments</comments>
		<pubDate>Wed, 26 May 2010 13:00:28 +0000</pubDate>
		<dc:creator>Pau Gay</dc:creator>
				<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programacion]]></category>

		<guid isPermaLink="false">http://paugay.com/blog/?p=368</guid>
		<description><![CDATA[¡Porfin lo encontré! En PHP hacemos el típico foreach: foreach&#40;$array as $key =&#38;gt; $value&#41; &#123; echo &#34;clave = &#34; + $key; echo &#34;valor = &#34; + $value; &#125; Y en Javascript también se puede hacer del siguiente modo: for&#40;i in array&#41; &#123; alert&#40;&#34;clave = &#34; + i&#41;; alert&#40;&#34;value = &#34; + array&#91;i&#93;&#41;; &#125;]]></description>
			<content:encoded><![CDATA[<p>¡Porfin lo encontré!</p>
<p>En <strong>PHP</strong> hacemos el típico foreach:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;clave = &quot;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$key</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;valor = &quot;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Y en <strong>Javascript</strong> también se puede hacer del siguiente modo:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i <span style="color: #000066; font-weight: bold;">in</span> array<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;clave = &quot;</span> <span style="color: #339933;">+</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;value = &quot;</span> <span style="color: #339933;">+</span> array<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://paugay.com/blog/2010/05/iterar-array-php-javascript.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Modificar TITLE desde el código (HTML)</title>
		<link>http://paugay.com/blog/2009/05/html-modificar-titl.html</link>
		<comments>http://paugay.com/blog/2009/05/html-modificar-titl.html#comments</comments>
		<pubDate>Sat, 16 May 2009 10:57:55 +0000</pubDate>
		<dc:creator>Pau Gay</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programacion]]></category>

		<guid isPermaLink="false">http://paugay.com/?p=238</guid>
		<description><![CDATA[Por temas de SEO necesito modificar el título de cada página dentro del código, es decir, fuera del &#60;header&#62;&#60;/header&#62;. He encontrado esta solución: &#60;?php $nombre_titulo=&#34;Este es el titulo&#34;; ?&#62; &#60;script language=&#34;javascript&#34;&#62; window.document.title = &#34;&#60;?php echo $nombre_titulo; ?&#62;&#34; &#60;/script&#62; Alguien usa otra manera más cómoda?]]></description>
			<content:encoded><![CDATA[<p>Por temas de SEO necesito modificar el título de cada página dentro del código, es decir, fuera del <strong>&lt;header&gt;&lt;/header&gt;</strong>.</p>
<p>He encontrado esta solución:</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;">$nombre_titulo</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Este es el titulo&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;script language=&quot;javascript&quot;&gt;
window.document.title = &quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$nombre_titulo</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;
&lt;/script&gt;</pre></div></div>

<p>Alguien usa otra manera más cómoda?</p>
]]></content:encoded>
			<wfw:commentRss>http://paugay.com/blog/2009/05/html-modificar-titl.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>API de Google Translate</title>
		<link>http://paugay.com/blog/2009/05/api-google-translate.html</link>
		<comments>http://paugay.com/blog/2009/05/api-google-translate.html#comments</comments>
		<pubDate>Sat, 09 May 2009 09:26:06 +0000</pubDate>
		<dc:creator>Pau Gay</dc:creator>
				<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[programacion]]></category>

		<guid isPermaLink="false">http://paugay.com/?p=222</guid>
		<description><![CDATA[Esta mañana he jugado con la API de google translate. Ha sido bastante sencillo ya que hay muchos ejemplos en la web. En mi caso, tengo una aplicación bilingue donde los usuarios pueden escribir la descripción de un producto. La idea es que al cambiar de idioma se cambie el idioma de todo (incluido el [...]]]></description>
			<content:encoded><![CDATA[<p>Esta mañana he jugado con la <a href="http://code.google.com/intl/es-ES/apis/ajaxlanguage/documentation/">API de google translate</a>. Ha sido bastante sencillo ya que hay muchos ejemplos en la web.</p>
<p>En mi caso, tengo una aplicación bilingue donde los usuarios pueden escribir la descripción de un producto. La idea es que al cambiar de idioma se cambie el idioma de todo (incluido el texto insertado por el usuario).</p>
<p>Aquí os dejo el código de pruebas:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.google.com/jsapi&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
    google.<span style="color: #006633;">load</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;language&quot;</span>, <span style="color: #0000ff;">&quot;1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
    function translate<span style="color: #009900;">&#40;</span>source, dest<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        var div_source <span style="color: #339933;">=</span> document.<span style="color: #006633;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;my_div_&quot;</span> <span style="color: #339933;">+</span> source<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        var div_dest <span style="color: #339933;">=</span> document.<span style="color: #006633;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;my_div_&quot;</span> <span style="color: #339933;">+</span> dest<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        alert<span style="color: #009900;">&#40;</span>div_source.<span style="color: #006633;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        google.<span style="color: #006633;">language</span>.<span style="color: #006633;">translate</span><span style="color: #009900;">&#40;</span>div_source.<span style="color: #006633;">value</span>, source, dest, function<span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            alert<span style="color: #009900;">&#40;</span>result.<span style="color: #006633;">translation</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>result.<span style="color: #006633;">error</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            div_dest.<span style="color: #006633;">value</span> <span style="color: #339933;">=</span> result.<span style="color: #006633;">translation</span><span style="color: #339933;">;</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: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Pues esto es todo.</p>
]]></content:encoded>
			<wfw:commentRss>http://paugay.com/blog/2009/05/api-google-translate.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Seleccionar directorio en HTML</title>
		<link>http://paugay.com/blog/2009/03/seleccionar-directorio-en-html.html</link>
		<comments>http://paugay.com/blog/2009/03/seleccionar-directorio-en-html.html#comments</comments>
		<pubDate>Mon, 30 Mar 2009 12:37:55 +0000</pubDate>
		<dc:creator>Pau Gay</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programacion]]></category>

		<guid isPermaLink="false">http://paugay.com/?p=203</guid>
		<description><![CDATA[Me surge la necesidad de seleccionar un path en un formulario HTML. Buscando he encontrado como seleccionar un fichero: &#60;input type=&#34;file&#34; &#91;...&#93; &#62; En muchos foros de Javascript y HTML se comenta que no es posible. Voy a seguir buscando pero si no encuentro nada parece que voy a tener que desarrollar un applet en [...]]]></description>
			<content:encoded><![CDATA[<p>Me surge la necesidad de seleccionar un path en un formulario HTML.</p>
<p>Buscando he encontrado como seleccionar un fichero:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;file&quot;</span> <span style="color: #009900;">&#91;</span><span style="color: #339933;">...</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span></pre></div></div>

<p>En muchos foros de Javascript y HTML se comenta que no es posible. Voy a seguir buscando pero si no encuentro nada parece que voy a tener que desarrollar un applet en Java para ello.</p>
<p>Si alguien ha dado con la solución que me ayude! Si no ya subiré como lo he hecho &#8230;</p>
<p>keywords: <strong>selecting folder path HTML<br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://paugay.com/blog/2009/03/seleccionar-directorio-en-html.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Javascript: Coger la etiqueta de un select</title>
		<link>http://paugay.com/blog/2009/01/javascript-coger-la-etiqueta-de-un-select.html</link>
		<comments>http://paugay.com/blog/2009/01/javascript-coger-la-etiqueta-de-un-select.html#comments</comments>
		<pubDate>Tue, 20 Jan 2009 18:52:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[programacion]]></category>

		<guid isPermaLink="false">http://root.elr1c.es/paugay/?p=98</guid>
		<description><![CDATA[Hoy me he estado un buen rato para una tontería: No sabía como recuperar la etiqueta (label) de un elemento select de un formulario. Tengo un formulario HTML con 3 campos, un input de texto para la dirección y dos seleccionables con la región y el municipio (imaginaos que es mi dirección postal). La idea [...]]]></description>
			<content:encoded><![CDATA[<p>Hoy me he estado un buen rato para una tontería:</p>
<blockquote style="font-weight: bold;"><p>No sabía como recuperar la etiqueta (label) de un elemento select de un formulario.</p></blockquote>
<p>Tengo un formulario HTML con 3 campos, un input de texto para la dirección y dos seleccionables con la región y el municipio (imaginaos que es mi dirección postal).</p>
<p>La idea era concatenar los 3 campos para llamar a <span style="font-weight: bold;">GClientGeocoder</span> y que me devuelva la <span style="font-weight: bold;">longitud</span> y la <span style="font-weight: bold;">latitud</span> de donde se encuentra mi casa. El problema es que la región y el municipio los guardo como identificador y lo que yo quería recuperar era la etiqueta.</p>
<p>La solución es sencilla (gracias a mi compañero <a href="http://miguelflorido.net">Miguel</a>):</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> add <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'add'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> cmb_loc <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id_loc'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> cmb_reg <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id_reg'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> loc <span style="color: #339933;">=</span> cmb_loc.<span style="color: #660066;">options</span><span style="color: #009900;">&#91;</span>cmb_loc.<span style="color: #660066;">selectedIndex</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">text</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> reg <span style="color: #339933;">=</span> cmb_reg.<span style="color: #660066;">options</span><span style="color: #009900;">&#91;</span>cmb_reg.<span style="color: #660066;">selectedIndex</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">text</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> address <span style="color: #339933;">=</span> add.<span style="color: #660066;">value</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">', '</span> <span style="color: #339933;">+</span> reg <span style="color: #339933;">+</span> <span style="color: #3366CC;">', '</span> <span style="color: #339933;">+</span> loc<span style="color: #339933;">;</span></pre></div></div>

<p>En address ya tenemos la concatenación de los 3 elementos.<br />
<span style="font-style: italic;">Nota: Pues eso &#8230; </span><a style="font-style: italic;" href="http://es.wikipedia.org/wiki/Obama">Obama</a><span style="font-style: italic;"> ya es presidente y el </span><a style="font-style: italic;" href="http://www.spotify.com/">Spotify</a><span style="font-style: italic;"> mola mucho.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://paugay.com/blog/2009/01/javascript-coger-la-etiqueta-de-un-select.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

