<?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>Ordo Ab Chao - Il blog di Rocco Agostino &#187; JavaScript &amp; AJAX</title>
	<atom:link href="http://blog.roccoagostino.eu/category/informatica/javascript-ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.roccoagostino.eu</link>
	<description>Il mio blog personale in cui si discute di libri,musica,scrittura,poesia,video,foto,news,attualità,informatica e tecnologia. Un &#34;corner&#34; da condividere con voi che commentate,criticate o apprezzate.</description>
	<lastBuildDate>Sat, 10 Apr 2010 17:02:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Uso di jQuery per creare una semplice interfaccia tab con immagini per etichette</title>
		<link>http://blog.roccoagostino.eu/2009/09/06/uso-di-jquery-per-creare-una-semplice-interfaccia-tab-con-immagini-per-etichette/</link>
		<comments>http://blog.roccoagostino.eu/2009/09/06/uso-di-jquery-per-creare-una-semplice-interfaccia-tab-con-immagini-per-etichette/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 22:29:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[JavaScript & AJAX]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[programmazione]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=225</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/ajax_ico.png" width="32" height="32" alt="" title="JavaScript &amp; AJAX" /><br/>Un effetto molto gradevole ed utile nell’economia di un sito web è senz’altro un’interfaccia a tab. JQuery permette di crearne di complesse ma la volontà di questo articolo è descriverne uno base, semplice, ma comunque funzionale e facilmente adattabile a molte esigenze. Il risultato è questo: demo Nel pacchetto oltre allo script jQuery, troverete anche [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/ajax_ico.png" width="32" height="32" alt="" title="JavaScript &amp; AJAX" /><br/><p>Un effetto molto gradevole ed utile nell’economia di un sito web è senz’altro un’interfaccia a tab. JQuery permette di crearne di complesse ma la volontà di questo articolo è descriverne uno base, semplice, ma comunque funzionale e facilmente adattabile a molte esigenze.</p>
<p>
Il risultato è questo: <a href="http://www.roccoagostino.eu/demo/navtab/index.html" target="_blank">demo</a><br />
<br />
Nel pacchetto Note: There is a file embedded within this post, please visit this post to download the file.<br />
oltre allo script <a href="http://www.jquery.com/" target="_blank">jQuery</a>, troverete anche i file e la cartella:</p>
<ul>
<li>index.htm</li>
<li>style.css</li>
<li>scripts.js</li>
<li>cartella images</li>
</ul>
<h2><strong>Passo 1 – creazione delle immagini</strong></h2>
<p>Decidete quanti tab sono necessari al vostro progetto (nel mio caso 3). Se non siete bravi in grafica e design cercate su internet le immagini che concettualmente si avvicinano al contenuto di ogni tab.<br />
Modificate le dimensioni tenendo conto dello spazio che volete utilizzare.<br />
A questo  punto duplicate la vostra immagine e  modificatela con effetti a piacere. Una volta terminato, create una nuova immagine ed incollate sopra la figura modificata e sotto la figura originale. (vedi immagine)<br />
<a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/09/doppia-immagine.PNG"><img class="aligncenter size-full wp-image-226" title="doppia immagine" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/09/doppia-immagine.PNG" alt="doppia immagine" width="559" height="221" /></a><br />
</p>
<h2><strong>Passo 2 – file HTML e CSS</strong></h2>
<p>Se aprite il file index.html troverete:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tabMenu&quot;</span>&gt;</span>  
     <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tabrss selected&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span> <span style="color: #808080; font-style: italic;">&lt;!-- bottone di default--&gt;</span>  
     <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tabpost&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>  
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tabcom&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>  
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span></pre></div></div>

<p>Nel file style.css, il div &#8220;tabMenu&#8221; è associato a:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">li<span style="color: #6666ff;">.tabcom</span>  <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">images/tabcom.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-77px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
li<span style="color: #6666ff;">.tabrss</span>  <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">images/tabrss.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-77px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
li<span style="color: #6666ff;">.tabpost</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">images/tabpost.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-77px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>  
li<span style="color: #6666ff;">.mouseover</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
li<span style="color: #6666ff;">.mouseout</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">-77px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
li<span style="color: #6666ff;">.selected</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Come potete notare di default l&#8217;immagine (di dimensioni 77px / 77px) parte da -77 px (quindi viene vusualizzata la sezione a colori), se si passa il cursore del mouse sopra (voce &#8220;li.mouseover&#8221; nel file style.css) parte da 0 px (quindi viene visualizzata la sezione in b/n), così come quando viene selezionata (voce &#8220;li.mouseover&#8221; nel file style.css). Quindi avremo, a secondo i casi, una situazione del genere:<br />
<a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/09/colore_bn.PNG"><img class="aligncenter size-full wp-image-227" title="colore_bn" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/09/colore_bn.PNG" alt="colore_bn" width="328" height="286" /></a><br />
Il contenuto delle tre  tab (ma se ne possono aggiungere altre a piacere) andrà inserito nella seguente struttura contenuta nel file index.html:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;boxBody&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;posts&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;show&quot;</span>&gt;</span>    <span style="color: #808080; font-style: italic;">&lt;!-- pagina di default--&gt;</span>  
&nbsp;
......................<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;famous&quot;</span>&gt;</span>
&nbsp;
...............<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;comments&quot;</span>&gt;</span>
&nbsp;
.................<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p>Ovviamente bisogna lavorare di CSS per rendere il tutto più gradevole.<br />
</p>
<h2><strong>Passo 3 – file JS</strong></h2>
<p>Nel file script.js è contenuta la funzione per la gestione dei tab con l&#8217;effetto a finestra nel cambio tra un tab e l&#8217;altro.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//nasconde il tab precedente</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.boxBody div'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//visualizza il tab selezionato</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.boxBody div:eq('</span> <span style="color: #339933;">+</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#tabMenu &amp;gt; li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">index</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">')'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideDown</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'1500'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In questo modo utilizziamo solo la libreria jQuery. Se voglamo altri effetti, come il fade alle immagini (invece della tecnica sopra illustrata) o altri effetti sul contenuto dei tab, ovviamente il file script.js sarà più complicato ed inoltre sarà necessario caricare i plugin di jQuery.</p>
<p>Enjoy it!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2009/09/06/uso-di-jquery-per-creare-una-semplice-interfaccia-tab-con-immagini-per-etichette/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Aggiungi/Rimuovi/Sposta una riga della tabella con jQuery</title>
		<link>http://blog.roccoagostino.eu/2009/08/29/aggiungirimuovisposta-riga-della-tabella-con-jquery/</link>
		<comments>http://blog.roccoagostino.eu/2009/08/29/aggiungirimuovisposta-riga-della-tabella-con-jquery/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 07:21:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[JavaScript & AJAX]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[programmazione]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=156</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/ajax_ico.png" width="32" height="32" alt="" title="JavaScript &amp; AJAX" /><br/>Segue da&#8230;.questo articolo Dopo aver capito come gestire dinamicamente la struttura di una tabella utilizzando il &#8220;div&#8221; ho voluto un pò complicare il tutto aggiungendo la possibilità di effettuare il drag and drop di una riga. Il risultato è questo: demo Nel pacchetto oltre allo script jQuery, troverete anche i file: index.htm scripts.js jquery.tablednd_0_5.js &#8230; [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/ajax_ico.png" width="32" height="32" alt="" title="JavaScript &amp; AJAX" /><br/><p>Segue da&#8230;.<a href="http://blog.roccoagostino.eu/2009/08/25/uso-di-jquery-per-aggiungererimuovere-un-campo-in-un-form/">questo articolo</a></p>
<p>Dopo aver capito come gestire dinamicamente la struttura di una tabella utilizzando il &#8220;div&#8221; ho voluto un pò complicare il tutto aggiungendo la possibilità di effettuare il drag and drop di una riga.</p>
<p>Il risultato è questo: <a href="http://www.roccoagostino.eu/demo/gesttab/index.htm" target="_black">demo</a></p>
<p>Nel pacchetto Note: There is a file embedded within this post, please visit this post to download the file.<br />
oltre allo script <a href="http://www.jquery.com/" target="_blank">jQuery</a>, troverete anche i file:</p>
<ul>
<li>index.htm</li>
<li>scripts.js</li>
<li>jquery.tablednd_0_5.js   &#8230;<a href="http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/" target="_blank"> approfondimento</a></li>
</ul>
<h2><strong>Passo 1 &#8211; file HTML</strong></h2>
<p>Riga di codice importantissima da non modificare:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">table</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;campi&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">table</span>&gt;</span></pre></div></div>

<p>infatti è all&#8217;interno di questo &#8220;table&#8221; che verranno creati i vari campi di input, contenuti nelle righe create dinamicamente. Come potete notare non uso più il &#8220;div&#8221; (vedi <a href="http://blog.roccoagostino.eu/2009/08/25/uso-di-jquery-…mpo-in-un-form/">articolo precedente</a>).</p>
<h2><strong>Passo 2 &#8211; file JS</strong></h2>
<p>Vi sono quattro funzioni:</p>
<p>La funzione <strong>addFormField()</strong> inserice una riga nella tabella contenente il campo di input.<br />
La funzione <strong>removeFormField()</strong> rimuove la riga selezionata dalla tabella e richiamando la funzione <strong>aggiorna()</strong>, riodina le etichette dei campi in ordine numerico crescente.<br />
La funzione <strong>inizializza_tabella()</strong> usa la libreria &#8220;jquery.tablednd_0_5.js&#8221; e rinizializza la tabella per il drag &amp; drop delle righe. Usa volta effettuato lo spostamento della riga, le etichette dei campi verranno riaggiornate. </p>
<p>Di seguito il codice:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> inizializza_tabella<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;">'#campi'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">tableDnD</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        onDrop<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>table<span style="color: #339933;">,</span> row<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            aggiorna<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: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> addFormField<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> id <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#campi tr[id^=&quot;row&quot;]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#campi&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'
&nbsp;
Campo '</span><span style="color: #339933;">+</span>id<span style="color: #339933;">+</span><span style="color: #3366CC;">'
&lt;input id=&quot;txt'</span><span style="color: #339933;">+</span>id<span style="color: #339933;">+</span><span style="color: #3366CC;">'&quot; name=&quot;txt[]&quot; size=&quot;25&quot; type=&quot;text&quot; /&gt;
&lt;a onclick=&quot;removeFormField($(this).parent());return false;&quot; href=&quot;#&quot;&gt;&lt;img src=&quot;img/edit_remove.png&quot; border=&quot;0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&nbsp;
'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;valore_c&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Campi inseriti: &amp;lt; &quot;</span><span style="color: #339933;">+</span>id<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot; &amp;gt;&quot;</span><span style="color: #339933;">;</span>
	inizializza_tabella<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> aggiorna<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> index <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span> <span style="color: #339933;">;</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#campi tr&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
          i<span style="color: #339933;">++;</span> index<span style="color: #339933;">=</span>i<span style="color: #339933;">;</span>
	      $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'row'</span><span style="color: #339933;">+</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		  <span style="color: #003366; font-weight: bold;">var</span> currentVal <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		  $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'
Campo '</span><span style="color: #339933;">+</span>i<span style="color: #339933;">+</span><span style="color: #3366CC;">'
&lt;input id=&quot;txt'</span><span style="color: #339933;">+</span>i<span style="color: #339933;">+</span><span style="color: #3366CC;">'&quot; name=&quot;txt[]&quot; size=&quot;25&quot; type=&quot;text&quot; value=&quot;'</span><span style="color: #339933;">+</span>currentVal<span style="color: #339933;">+</span><span style="color: #3366CC;">'&quot; /&gt;
&lt;a onclick=&quot;removeFormField($(this).parent());return false;&quot; href=&quot;#&quot;&gt;&lt;img src=&quot;img/edit_remove.png&quot; border=&quot;0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&nbsp;
'</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;valore_c&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Campi inseriti: &amp;lt; &quot;</span><span style="color: #339933;">+</span>index<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot; &amp;gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> removeFormField<span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span>el.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    aggiorna<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   	inizializza_tabella<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: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2009/08/29/aggiungirimuovisposta-riga-della-tabella-con-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Uso di jQuery per aggiungere/rimuovere un campo in un form</title>
		<link>http://blog.roccoagostino.eu/2009/08/25/uso-di-jquery-per-aggiungererimuovere-un-campo-in-un-form/</link>
		<comments>http://blog.roccoagostino.eu/2009/08/25/uso-di-jquery-per-aggiungererimuovere-un-campo-in-un-form/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 16:07:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[JavaScript & AJAX]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[programmazione]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=114</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/ajax_ico.png" width="32" height="32" alt="" title="JavaScript &amp; AJAX" /><br/>Per un progetto che sto sviluppando ho avuto la necessità di crare una tabella non conoscendo a priori i campi che la componevano. Cioè la tabella doveva essere creata in maniera dinamica, con la possibilità di aggiungere o rimuovere i campi a piacere durante la creazione. Dopo un attenta analisi e un approfondito studio sull&#8217;argomento [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/ajax_ico.png" width="32" height="32" alt="" title="JavaScript &amp; AJAX" /><br/><p>Per un progetto che sto sviluppando ho avuto la necessità di crare una tabella non conoscendo a priori i campi che la componevano. Cioè la tabella doveva essere creata in maniera dinamica, con la possibilità di aggiungere o rimuovere i campi a piacere durante la creazione. Dopo un attenta analisi e un approfondito studio sull&#8217;argomento ho risolto utilizzando le librerie <a href="http://www.jquery.com/" target="_blank">jQuery.</a></p>
<p>Il risultato è questo: <a href="http://www.roccoagostino.eu/demo/addremfieldform/index.htm" target="_black">demo</a></p>
<p>Nel pacchetto Note: There is a file embedded within this post, please visit this post to download the file.<br />
oltre allo script jQuery, troverete anche i file:</p>
<ul>
<li>index.htm</li>
<li>scripts.js</li>
</ul>
<h2><strong>Passo 1 &#8211; file HTML</strong></h2>
<p>Riga di codice importantissima da non modificare:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;campi&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p>infatti è all&#8217;interno di questo &#8220;div&#8221; che verranno costruiti i vari campi.</p>
<h2><strong>Passo 2 &#8211; file JS</strong></h2>
<p>Vi sono due funzioni:</p>
<p>La funzione <strong>addFormField()</strong> crea un campo di input e lo inserisce nel form. Supponendo, per esempio, di inserire due campi, all&#8217;interno del &#8220;div&#8221; di cui sopra compariranno le linee di codice:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>p id<span style="color: #339933;">=</span><span style="color: #3366CC;">'row1'</span><span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;</span>label <span style="color: #000066; font-weight: bold;">for</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'txt1'</span><span style="color: #339933;">&gt;</span>Campo <span style="color: #CC0000;">1</span><span style="color: #339933;">&amp;</span>nbsp<span style="color: #339933;">;</span>
       <span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #3366CC;">'text'</span> size<span style="color: #339933;">=</span><span style="color: #3366CC;">'20'</span> <span style="color: #000066;">name</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'txt[]'</span> id<span style="color: #339933;">=</span><span style="color: #3366CC;">'txt1'</span><span style="color: #339933;">/&gt;&amp;</span>nbsp<span style="color: #339933;">;&amp;</span>nbsp<span style="color: #339933;">;</span>
       <span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #3366CC;">'#'</span> onClick<span style="color: #339933;">=</span><span style="color: #3366CC;">'removeFormField(&quot;#row1&quot;); return false;'</span><span style="color: #339933;">&gt;</span>Rimuovi<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;/</span>label<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>p id<span style="color: #339933;">=</span><span style="color: #3366CC;">'row2'</span><span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;</span>label <span style="color: #000066; font-weight: bold;">for</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'txt2'</span><span style="color: #339933;">&gt;</span>Campo <span style="color: #CC0000;">2</span><span style="color: #339933;">&amp;</span>nbsp<span style="color: #339933;">;</span>
     <span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #3366CC;">'text'</span> size<span style="color: #339933;">=</span><span style="color: #3366CC;">'20'</span> <span style="color: #000066;">name</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'txt[]'</span> id<span style="color: #339933;">=</span><span style="color: #3366CC;">'txt2'</span><span style="color: #339933;">/&gt;&amp;</span>nbsp<span style="color: #339933;">;&amp;</span>nbsp<span style="color: #339933;">;</span>
     <span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #3366CC;">'#'</span> onClick<span style="color: #339933;">=</span><span style="color: #3366CC;">'removeFormField(&quot;#row2&quot;); return false;'</span><span style="color: #339933;">&gt;</span>Rimuovi<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;/</span>label<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Ho inserito &#8220;Rimuovi&#8221; invece dell&#8217;immagine dell&#8217;esempio.<br />
Come potete notare, il &#8220;form&#8221; restituirà un array &#8220;txt[]&#8221; contenente i valori dei campi; tale array sarà possibile processarlo, per esempio, richiamando da &#8220;form&#8221; un file php.</p>
<p>La funzione <strong>removeFormField()</strong> oltre a rimuovere il campo desiderato riordina i rimanenti campi.</p>
<p>Continua con&#8230;<a href="http://blog.roccoagostino.eu/2009/08/29/aggiungirimuovisposta-riga-della-tabella-con-jquery/">questo articolo</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2009/08/25/uso-di-jquery-per-aggiungererimuovere-un-campo-in-un-form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Uso di jQuery per creare una interfaccia tabs per i video</title>
		<link>http://blog.roccoagostino.eu/2009/08/21/uso-di-jquery-per-creare-una-interfaccia-tabs-per-i-video/</link>
		<comments>http://blog.roccoagostino.eu/2009/08/21/uso-di-jquery-per-creare-una-interfaccia-tabs-per-i-video/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 09:17:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[JavaScript & AJAX]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[programmazione]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=21</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/ajax_ico.png" width="32" height="32" alt="" title="JavaScript &amp; AJAX" /><br/>Avendo la necessità di inserire molti link a video pubblici, ho cercato un modo di raggruppare questi video in un unico box, selezionandoli quindi in qualche maniera, in parole povere come se avessi di fronte un televisore con la possibilità di cambiare canale. Navigando su internet ho trovato la risposta al mio problema, utilizzano le [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/ajax_ico.png" width="32" height="32" alt="" title="JavaScript &amp; AJAX" /><br/><p>Avendo la necessità di inserire molti link a video pubblici, ho cercato un modo di raggruppare questi video in un unico box, selezionandoli quindi in qualche maniera, in parole povere come se avessi di fronte un televisore con la possibilità di cambiare canale.<br />
Navigando su internet ho trovato la risposta al mio problema, utilizzano le librerie <a href="http://www.jquery.com/" target="_blank">jQuery.</a></p>
<p>Il risultato è questo:<br />
<!--/featuredvid--></p>
<div id="featuredvid" class="scatola">
<div id="vid-1" class="fvid"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/DmpItalFd5Q&amp;hl=it&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/DmpItalFd5Q&amp;hl=it&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></div>
<div id="vid-2" class="fvid"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/T4snBv54Ybc&amp;hl=it&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/T4snBv54Ybc&amp;hl=it&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></div>
<div id="vid-3" class="fvid"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/ryoGgPNx6wI&amp;hl=it&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/ryoGgPNx6wI&amp;hl=it&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></div>
<p><span style="color: red; font-size: xx-small;"><strong>VIDEOTECA</strong></span></p>
<ul class="vidselector">
<li><a href="#vid-1">UFO e EXTRATERRESTRI &#8211; Rivelazioni</a></li>
<li><a href="#vid-2">Video di UFO rilasciati dai militari e dalle autorità</a></li>
<li><a href="#vid-3">Autopsia dell&#8217;Alieno di Rosewell</a></li>
</ul>
</div>
<p><!--/featuredvid--></p>
<p>Per creare questo effetto quindi bisogna scaricare <a href="http://www.jquery.com/" target="_blank">jQuery.</a> e <a href="http://jqueryui.com/download/" target="_blank">jQuery UI</a> con gli elementi ‘Core’ and ‘Tabs’.<br />
Nel pacchetto Note: There is a file embedded within this post, please visit this post to download the file.<br />
oltre agli script jQuery, trovere anche i file:</p>
<ul>
<li>index.htm</li>
<li>videoteca.css</li>
<li>scripts.js</li>
</ul>
<h2><strong>Passo 1 &#8211; file HTML</strong></h2>
<p>Per aggiungere altri video basta aggiungere altri</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;vid-x&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;fvid&quot;</span>&gt;</span>yyyyyyyyyyy<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p>e quindi altri link</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#vid-x&quot;</span>&gt;</span>kkkkkkkkkkkk<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span></pre></div></div>

<h2><strong>Passo 2 &#8211; file CSS</strong></h2>
<p>Modificare a piacere lo stile per cambiare l&#8217;aspetto grafico.</p>
<h2><strong>Passo 3 &#8211; file JS</strong></h2>
<p>Può essere incluso all&#8217;interno del file html con</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
jQuery<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>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;">'#featuredvid'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">tabs</span><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: #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>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2009/08/21/uso-di-jquery-per-creare-una-interfaccia-tabs-per-i-video/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
