<?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>vijayjoshi.org &#187; jQuery</title>
	<atom:link href="http://www.vijayjoshi.org/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vijayjoshi.org</link>
	<description>php &#124; javascript &#124; ajax &#124; and all things web</description>
	<lastBuildDate>Sun, 20 Nov 2011 15:24:32 +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>Favorite tech links of the week : 17 Jan – 23 Jan, 2011</title>
		<link>http://www.vijayjoshi.org/2011/01/24/favorite-tech-links-of-the-week-17-jan23-jan-2011/</link>
		<comments>http://www.vijayjoshi.org/2011/01/24/favorite-tech-links-of-the-week-17-jan23-jan-2011/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 06:09:00 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[Resources]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=1169</guid>
		<description><![CDATA[
			
				
			
		
This post contains some of the useful and interesting tech links I found during last week. To keep up to date with the latest information, subscribe to the feed or follow me on twitter @v08i.
How to write a simple application on jQuery Mobile : http://goo.gl/5DpOO

50 Free Tools and Apps for Web Designers and Developers : http://goo.gl/6YjNL

10 Useful jQuery Plugins for Images : ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2011%2F01%2F24%2Ffavorite-tech-links-of-the-week-17-jan23-jan-2011%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2011%2F01%2F24%2Ffavorite-tech-links-of-the-week-17-jan23-jan-2011%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>This post contains some of the useful and interesting tech links I found during last week. To keep up to date with the latest information, <a title="Subscribe" href="http://vijayjoshi.org/feed">subscribe to the feed</a> or follow me on twitter <a title="Follow me on Twitter" href="http://twitter.com/v08i">@v08i</a>.</p>
<h4>How to write a simple application on jQuery Mobile : <a href="http://goo.gl/526cL">http://goo.gl/5DpOO</a></h4>
<p style="text-align: center;"><a href="http://goo.gl/526cL"><img class="aligncenter size-full wp-image-1170" title="jQuery Mobile" src="http://www.vijayjoshi.org/wp-content/uploads/jQueryMobile.png" alt="jQuery Mobile" /></a></p>
<h4>50 Free Tools and Apps for Web Designers and Developers : <a href="http://goo.gl/6YjNL">http://goo.gl/6YjNL</a></h4>
<p style="text-align: center;"><a href="http://goo.gl/6YjNL"><img class="aligncenter size-full wp-image-1171" title="50 Free tools for developers" src="http://www.vijayjoshi.org/wp-content/uploads/50tools.png" alt="50 Free tools for developers" width="527" height="194" /></a></p>
<h4>10 Useful jQuery Plugins for Images : <a href="http://goo.gl/VTk1F">http://goo.gl/VTk1F</a></h4>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-1172" title="jQuery Image Tools" src="http://www.vijayjoshi.org/wp-content/uploads/jQueryFaceDetection.png" alt="jQuery Image Tools" width="484" height="321" /></p>
<h4>20 less known Open Source PHP CMS-es : <a href="http://goo.gl/cM6f3">http://goo.gl/cM6f3</a></h4>
<p style="text-align: center;"><a href="http://goo.gl/cM6f3"><img class="aligncenter size-full wp-image-1173" title="php Cms" src="http://www.vijayjoshi.org/wp-content/uploads/phpCmses.png" alt="php Cms" width="494" height="372" /></a></p>
<h4>11 More Things I Learned From the jQuery Source : <a href="http://goo.gl/2zBh7">http://goo.gl/2zBh7</a></h4>
<p style="text-align: center;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="350" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/ARnp9Y8xgR4" /><embed type="application/x-shockwave-flash" width="425" height="350" src="http://www.youtube.com/v/ARnp9Y8xgR4"></embed></object></p>
<h4>CSSReset : All the most common CSS Reset scripts in one place : <a href="http://goo.gl/8OV9E">http://goo.gl/8OV9E</a></h4>
<p style="text-align: center;"><a href="http://goo.gl/8OV9E"><img class="aligncenter size-full wp-image-1174" title="CSS Resets" src="http://www.vijayjoshi.org/wp-content/uploads/CSSResets.png" alt="CSS Resets" width="508" height="413" /></a></p>
<h4>JavaScript Slider – TinySlider 2 : <a href="http://goo.gl/526cL">http://goo.gl/526cL</a></h4>
<p style="text-align: center;"><a href="http://goo.gl/526cL"><img class="aligncenter size-full wp-image-1175" title="js Slider" src="http://www.vijayjoshi.org/wp-content/uploads/jsSlider.png" alt="js Slider" width="482" height="193" /></a></p>
<div class="shr-publisher-1169"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2011%2F01%2F24%2Ffavorite-tech-links-of-the-week-17-jan23-jan-2011%2F' data-shr_title='Favorite+tech+links+of+the+week+%3A+17+Jan+%E2%80%93+23+Jan%2C+2011'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2011/01/24/favorite-tech-links-of-the-week-17-jan23-jan-2011/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Searching text in a HTML table using jQuery</title>
		<link>http://www.vijayjoshi.org/2011/01/03/searching-text-in-a-html-table-using-jquery/</link>
		<comments>http://www.vijayjoshi.org/2011/01/03/searching-text-in-a-html-table-using-jquery/#comments</comments>
		<pubDate>Mon, 03 Jan 2011 12:31:01 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=982</guid>
		<description><![CDATA[
			
				
			
		

Here is the situation. You have a really long table with hundreds of rows and you want to filter the rows(instantly!) that contain a specific keyword in any of the table cells.
This article will show how this can be achieved with the help of jQuery.

The HTML
Create a table with some rows with multiple cells. Put a textbox above the table ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2011%2F01%2F03%2Fsearching-text-in-a-html-table-using-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2011%2F01%2F03%2Fsearching-text-in-a-html-table-using-jquery%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: left;"><img class="aligncenter size-full wp-image-983" title="Filter Table" src="http://www.vijayjoshi.org/wp-content/uploads/filterTable.png" alt="Filter Table" width="539" height="381" /></p>
<p>Here is the situation. You have a really long table with hundreds of rows and you want to filter the rows(instantly!) that contain a specific keyword in any of the table cells.</p>
<p>This article will show how this can be achieved with the help of jQuery.</p>
<p><a href="http://www.vijayjoshi.org/examples/filterTable.html" target="_blank"><img class="size-full wp-image-453 aligncenter" title="View Demo" src="http://www.vijayjoshi.org/wp-content/uploads/demo.png" alt="View Demo" width="144" height="36" /></a><span id="more-982"></span></p>
<p><strong>The HTML</strong></p>
<p>Create a table with some rows with multiple cells. Put a textbox above the table in which search term will be entered.</p>
<pre class="brush:xml">&lt;div class="tables"&gt;
	&lt;p&gt;
		&lt;label for="search"&gt;
			&lt;strong&gt;Enter keyword to search &lt;/strong&gt;
		&lt;/label&gt;
		&lt;input type="text" id="search"/&gt;
		&lt;label&gt;e.g. bar, parking, tv&lt;/label&gt;
	&lt;/p&gt;
	&lt;table width="100%" id="tblData" class="target" bgcolor="#ACAAFC"&gt;
		&lt;tbody&gt;
			&lt;tr&gt;
				&lt;th width="10%"&gt;#&lt;/th&gt;
				&lt;th width="35%"&gt;Hotel Name&lt;/th&gt;
				&lt;th width="55%"&gt;Facilities&lt;/th&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
				&lt;td class="odd"&gt;1&lt;/td&gt;
				&lt;td class="odd"&gt;Manu Maharani&lt;/td&gt;
				&lt;td class="odd"&gt;Attached Bath, Bar, Swimming Pool, &lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
				&lt;td class="even"&gt;2&lt;/td&gt;
				&lt;td class="even"&gt;Hill View&lt;/td&gt;
				&lt;td class="even"&gt;TV, In-Room Safe, Bar&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
				&lt;td class="odd"&gt;3&lt;/td&gt;
				&lt;td class="odd"&gt;Hotel Suba Galaxy&lt;/td&gt;
				&lt;td class="odd"&gt;Paid Internet Access, Coffee Shop, Spa&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
				&lt;td class="even"&gt;4&lt;/td&gt;
				&lt;td class="even"&gt;The Residence Hotel&lt;/td&gt;
				&lt;td class="even"&gt;Doctor on Call, Parking&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
				&lt;td class="odd"&gt;5&lt;/td&gt;
				&lt;td class="odd"&gt;The Taj&lt;/td&gt;
				&lt;td class="odd"&gt;Currency Exchange, Bar, Golf&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
				&lt;td class="even"&gt;6&lt;/td&gt;
				&lt;td class="even"&gt;Mumbai Grand&lt;/td&gt;
				&lt;td class="even"&gt;Jacuzzi, Spa, Coffee Shop&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
				&lt;td class="odd"&gt;7&lt;/td&gt;
				&lt;td class="odd"&gt;The Promenade&lt;/td&gt;
				&lt;td class="odd"&gt;Cable TV, Coffee Shop, Spa&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
				&lt;td class="even"&gt;8&lt;/td&gt;
				&lt;td class="even"&gt;Hotel Regency&lt;/td&gt;
				&lt;td class="even"&gt;Mini Bar,Golf, Spa, Sauna&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
				&lt;td class="odd"&gt;9&lt;/td&gt;
				&lt;td class="odd"&gt;Park Plaza&lt;/td&gt;
				&lt;td class="odd"&gt;Currency Exchange, Bar, Golf&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
				&lt;td class="even"&gt;10&lt;/td&gt;
				&lt;td class="even"&gt;The Mapple Inn&lt;/td&gt;
				&lt;td class="even"&gt;Jacuzzi, Spa, Coffee Shop&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
				&lt;td class="odd"&gt;11&lt;/td&gt;
				&lt;td class="odd"&gt;Cidade de Goa&lt;/td&gt;
				&lt;td class="odd"&gt;Cable TV, Coffee Shop, Spa&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
				&lt;td class="even"&gt;12&lt;/td&gt;
				&lt;td class="even"&gt;Saurabh Mountview&lt;/td&gt;
				&lt;td class="even"&gt;Doctor, Free Parking&lt;/td&gt;
			&lt;/tr&gt;
		&lt;/tbody&gt;
	&lt;/table&gt;
&lt;/div&gt;</pre>
<p><strong>The CSS</strong></p>
<p>Apply the following css to style the table and its cells.</p>
<pre class="brush:css">body
{
	font-family:verdana,arial;
	font-size:13px;
	margin:0 auto;
	width:100%;
}
.tables
{
	border:1px solid #000;
	margin:0 auto;
	width:600px;
}
th,td
{
	padding:5px;
}
p
{
	background-color:#ACAAFC;
	padding:10px;
}
a
{
	color:#fff;
	text-decoration:none;
}
.even
{
	background-color:#fff;
	color:#343234;
}
.odd
{
	background-color:#DCDEFC;
	color:#343234;
}</pre>
<p><strong>The jQuery Code</strong></p>
<pre class="brush:as3">$(document).ready(function()
{
	$('#search').keyup(function()
	{
		searchTable($(this).val());
	});
});

function searchTable(inputVal)
{
	var table = $('#tblData');
	table.find('tr').each(function(index, row)
	{
		var allCells = $(row).find('td');
		if(allCells.length &gt; 0)
		{
			var found = false;
			allCells.each(function(index, td)
			{
				var regExp = new RegExp(inputVal, 'i');
				if(regExp.test($(td).text()))
				{
					found = true;
					return false;
				}
			});
			if(found == true)$(row).show();else $(row).hide();
		}
	});
}</pre>
<p style="text-align: center;"><a href="http://www.vijayjoshi.org/examples/filterTable.html" target="_blank"><img class="aligncenter size-full wp-image-453" title="View Demo" src="http://www.vijayjoshi.org/wp-content/uploads/demo.png" alt="View Demo" width="162" height="41" /></a></p>
<p>The jQuery code is simple. <em><strong>searchTable </strong></em>function is called on <em><strong>keyup</strong></em> of textbox. We search for all <em><strong>td</strong></em> elements in each row and then check for the inputted value. A regular expression is used to match the values. If a match is not found, we hide that row. Passing <em><strong>i</strong></em> as second parameter makes the search case-insensitive. Remove it if you want a case-sensitive search.</p>
<p>Another point to note is that this code will not work on nested tables i.e. if you have more tables inside cells.</p>
<p>Future enhancements will include developing it as a simple jQuery plugin and support for searching in nested tables.</p>
<div class="shr-publisher-982"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2011%2F01%2F03%2Fsearching-text-in-a-html-table-using-jquery%2F' data-shr_title='Searching+text+in+a+HTML+table+using+jQuery'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2011/01/03/searching-text-in-a-html-table-using-jquery/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Why you MUST use client side validation</title>
		<link>http://www.vijayjoshi.org/2010/12/30/why-you-must-use-client-side-validation/</link>
		<comments>http://www.vijayjoshi.org/2010/12/30/why-you-must-use-client-side-validation/#comments</comments>
		<pubDate>Thu, 30 Dec 2010 06:03:48 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[browser]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=931</guid>
		<description><![CDATA[
			
				
			
		

Client side validation is checking the values against the desired format before sending them to server side for further processing. Javascript is used for validations on browser. Lately, with the popularity of jQuery, a large number of validation plugins are available which make it even more easy to implement validations on forms.
A word of caution before beginning. Though client side ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F30%2Fwhy-you-must-use-client-side-validation%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F30%2Fwhy-you-must-use-client-side-validation%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img class="aligncenter size-full wp-image-947" title="validation" src="http://www.vijayjoshi.org/wp-content/uploads/validation.png" alt="validation" /></p>
<p>Client side validation is checking the values against the desired format before sending them to server side for further processing. Javascript is used for validations on browser. Lately, with the popularity of jQuery, a large number of validation plugins are available which make it even more easy to implement validations on forms.</p>
<p>A word of caution before beginning. Though client side validation is very useful and simple to implement, it should <strong>NEVER </strong>be thought of as a replacement for server side validations. If the javascript is turned off on the browser or user bypasses it and no server side validation is placed, your application then is at the mercy of users solely.</p>
<p><del datetime="2010-12-30T05:11:22+00:00">Read Why you must use server side validation?</del></p>
<p>So, here is why you should use client side validation.</p>
<h3>Easy to implement</h3>
<p>Although you can write your own validation for forms, there are multiple <a title="Javascript validation plugin" href="http://www.validationplugin.com/">javascript</a> and <a title="jQuery Validation" href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/">jQuery</a> plugins available that require developers to write minimal amount of code to implement validation. These plugins also provide several options for customized validation like strings, numbers, dates, email addresses etc.</p>
<h3>No waiting time for users</h3>
<p>Since javascript executes on users browser itself, client side validation provides instant feedback. Plugins like <a title="Live Validation" href="http://livevalidation.com/">live validation</a> provide helpful messages to users as they type. Besides saving time, this pattern makes data entry less error prone.</p>
<h3>Less server trips</h3>
<p>Without javascript validation, each time a value needs to be checked, the form should be submitted and server would then process it and show the result. Take for example a text box which asks for email. Possible validations for it could be blank value and a valid email address. With javascript validations in place we can save these trips to server.</p>
<h3>Interactive and Fun</h3>
<p>Have a look at <a title="jQuery inline form validator" href="http://www.position-relative.net/creation/formValidator/">jQuery inline formValidator</a>. Gone are the days of ugly alert boxes (those were really irritating). With javascript running in browser, you can unleash your creativity and make validation an interactive and fun process by combining html and css with javascript. You can use tooltips and fancy effects to guide your users.</p>
<h3>Users love it</h3>
<p>Waiting for full page load only to see one error message is no good. Users like instant feedback and helpful error messages. Javascript allows you to create a rich visual experience that is a major trait of rich internet applications.</p>
<p>That&#8217;s it for now.</p>
<p>It is worth mentioning again that alone client side validation is no good. Always, I repeat, <strong>always use server side validation along with client side validation</strong>. This way, in case the javascript validation fails, you can always rely on the server.</p>
<p><a title="Form validation best practices" href="http://www.smashingmagazine.com/2009/07/07/web-form-validation-best-practices-and-tutorials/">Click here</a> to read more about best practices of form validation</p>
<div class="shr-publisher-931"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F30%2Fwhy-you-must-use-client-side-validation%2F' data-shr_title='Why+you+MUST+use+client+side+validation'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2010/12/30/why-you-must-use-client-side-validation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Favorite tech links of the week : 20Dec &#8211; 26Dec, 2010</title>
		<link>http://www.vijayjoshi.org/2010/12/27/favorite-tech-links-of-the-week-20dec-26dec-2010/</link>
		<comments>http://www.vijayjoshi.org/2010/12/27/favorite-tech-links-of-the-week-20dec-26dec-2010/#comments</comments>
		<pubDate>Mon, 27 Dec 2010 06:35:12 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[Resources]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=907</guid>
		<description><![CDATA[
			
				
			
		
This post contains some of the useful and interesting tech links I found during this week. To keep up to date with the latest information, subscribe to the feed or  follow me on twitter @v08i
jQuery 1.4.3 Offline Learning Kit &#8211; http://goo.gl/zoAb5

What features would you like to have in PHP? &#8211; http://goo.gl/Q84B9

35 Useful and Time saving Firefox Add-Ons &#8211; http://goo.gl/ZQQhF


Beware the ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F27%2Ffavorite-tech-links-of-the-week-20dec-26dec-2010%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F27%2Ffavorite-tech-links-of-the-week-20dec-26dec-2010%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>This post contains some of the useful and interesting tech links I found during this week. To keep up to date with the latest information, <a title="Subscribe" href="http://vijayjoshi.org/feed">subscribe to the feed</a> or  follow me on twitter <a title="Follow Vijay Joshi on Twitter" href="http://twitter.com/v08i">@v08i</a></p>
<h4>jQuery 1.4.3 Offline Learning Kit &#8211; <a title="jQuery Offline Learning Kit" href="http://goo.gl/zoAb5">http://goo.gl/zoAb5</a></h4>
<p style="text-align: center;"><a href="http://goo.gl/zoAb5"><img class="aligncenter size-full wp-image-911" title="jqkit" src="http://www.vijayjoshi.org/wp-content/uploads/jqkit.jpg" alt="jqkit" width="432" height="274" /></a></p>
<h4>What features would you like to have in PHP? &#8211; <a href="http://goo.gl/Q84B9">http://goo.gl/Q84B9</a></h4>
<p style="text-align: center;"><a href="http://goo.gl/Q84B9"><img class="aligncenter size-full wp-image-917" title="php" src="http://www.vijayjoshi.org/wp-content/uploads/php.png" alt="php" width="442" height="233" /></a></p>
<h4>35 Useful and Time saving Firefox Add-Ons &#8211; <a title="35 firefox addons" href="http://goo.gl/ZQQhF">http://goo.gl/ZQQhF</a></h4>
<p style="text-align: center;"><a href="http://goo.gl/ZQQhF"><img class="aligncenter size-full wp-image-914" title="firefox-wallpaper" src="http://www.vijayjoshi.org/wp-content/uploads/firefox-wallpaper.jpg" alt="firefox-wallpaper" width="399" height="250" /></a></p>
<h4><span id="more-907"></span></h4>
<h4>Beware the Trailing Comma of Death &#8211; <a href="http://goo.gl/P3LqX">http://goo.gl/P3LqX</a></h4>
<h4>2010: Yet another great year for PHP &#8211; <a href="http://goo.gl/WO0uY">http://goo.gl/WO0uY</a></h4>
<p style="text-align: center;"><a href="http://goo.gl/WO0uY"><img class="aligncenter size-full wp-image-916" title="php2011" src="http://www.vijayjoshi.org/wp-content/uploads/php2011.png" alt="php2011" width="350" height="394" /></a></p>
<h4>The major incidents on the Internet in 2010 &#8211; <a href="http://goo.gl/lbfM1">http://goo.gl/lbfM1</a></h4>
<p style="text-align: center;"><a href="http://goo.gl/lbfM1"><img class="aligncenter size-full wp-image-918" title="wikipedia" src="http://www.vijayjoshi.org/wp-content/uploads/wikipedia.png" alt="wikipedia" width="419" height="250" /></a></p>
<h4>Ten Alternative CMS Options to WordPress &#8211; <a href="http://goo.gl/1q9ly">http://goo.gl/1q9ly</a></h4>
<p style="text-align: center;"><a href="http://goo.gl/1q9ly"><img class="aligncenter size-full wp-image-912" title="cms" src="http://www.vijayjoshi.org/wp-content/uploads/cms.png" alt="cms" width="482" height="507" /></a></p>
<h4>3 Lightweight Alternatives to phpMyAdmin &#8211; <a href="http://goo.gl/izsZc">http://goo.gl/izsZc</a></h4>
<h4>Rocking Out With CoffeeScript &#8211; <a title="Coffeescript" href="http://goo.gl/5FCYl">http://goo.gl/5FCYl</a></h4>
<p style="text-align: center;"><strong><a href="http://goo.gl/5FCYl"><img class="aligncenter size-full wp-image-913" title="coffee" src="http://www.vijayjoshi.org/wp-content/uploads/coffee.png" alt="coffee" width="433" height="256" /></a><br />
</strong></p>
<h4>50 Best jQuery Techniques 2010 &#8211; <a title="jQuery Techniques" href="http://goo.gl/4TfBF">http://goo.gl/4TfBF</a></h4>
<p style="text-align: center;"><a href="http://goo.gl/4TfBF"><img class="aligncenter size-full wp-image-915" title="bestjOfQuery" src="http://www.vijayjoshi.org/wp-content/uploads/bestjOfQuery.PNG" alt="bestjOfQuery" width="490" height="332" /></a></p>
<div class="shr-publisher-907"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F27%2Ffavorite-tech-links-of-the-week-20dec-26dec-2010%2F' data-shr_title='Favorite+tech+links+of+the+week+%3A+20Dec+-+26Dec%2C+2010'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2010/12/27/favorite-tech-links-of-the-week-20dec-26dec-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Twitter API and jQuery to display recent tweets</title>
		<link>http://www.vijayjoshi.org/2010/12/24/using-twitter-api-and-jquery-to-display-recent-tweets/</link>
		<comments>http://www.vijayjoshi.org/2010/12/24/using-twitter-api-and-jquery-to-display-recent-tweets/#comments</comments>
		<pubDate>Fri, 24 Dec 2010 06:52:13 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JSON]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=886</guid>
		<description><![CDATA[
			
				
			
		
In this article I will show you how you can display your (or any other user&#8217;s) recent tweets with some jQuery magic. We will create a widget (sort of) that will fetch n number of latest tweets from public timeline of a user using Twitter API and then we will display them in a nice list.
End result will look like ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F24%2Fusing-twitter-api-and-jquery-to-display-recent-tweets%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F24%2Fusing-twitter-api-and-jquery-to-display-recent-tweets%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In this article I will show you how you can display your (or any other user&#8217;s) recent tweets with some jQuery magic. We will create a widget (sort of) that will fetch n number of latest tweets from public timeline of a user using Twitter API and then we will display them in a nice list.</p>
<p>End result will look like the following.</p>
<p style="text-align: left;"><img class="aligncenter size-full wp-image-887" title="tweets" src="http://www.vijayjoshi.org/wp-content/uploads/tweets.png" alt="tweets" width="480" height="388" /></p>
<p style="text-align: left;">Have a look at a live example.</p>
<p style="text-align: center;"><a href="http://vijayjoshi.org/examples/twitter-latest-tweets.html"><img class="size-full wp-image-453 aligncenter" title="View Demo" src="http://www.vijayjoshi.org/wp-content/uploads/demo.png" alt="View Demo" width="180" height="45" /></a></p>
<p style="text-align: left;">Let us start creating it now. First write some HTML. Define some css styles in the head section which will control the display of list. In the body section, there is a select box with id <strong><em>layout</em></strong> which will be used to select either a wide or a narrow layout for displaying the tweets. Then create a <strong><em>div </em></strong>with id <strong>tweets</strong>. We will create a <strong><em>ul</em></strong> inside this div which will have tweets as list items.</p>
<p style="text-align: left;"><span id="more-886"></span></p>
<p style="text-align: left;">
<p style="text-align: left;">
<pre class="brush:xml">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
	&lt;head&gt;
		&lt;title&gt;Latest Tweets Widget - Vijay Joshi | http://vijayjoshi.org&lt;/title&gt;
		&lt;style type="text/css"&gt;
			body{ margin:0;font-family:verdana,arial;font-size:13px;width:100%;}
			p{margin:0;padding:5px;}
			span{font-size: 10px; font-weight: bold;}
			#container{margin:0 auto;padding:5px;width:600px;}
			#tweets{background-color:#ACAAFC;}
			#tweets ul, li{list-style:none;margin:0;padding:5px;}
			#tweets h2{margin: 0pt; padding:5px;}
			#tweets a { color: #FF0000;}
			.even{ border-bottom: 1px dotted #000;color:#343234;background-color:#FCFEFC;}
			.odd{border-bottom: 1px dotted #000;color:#343234;background-color:#DCDEFC;}
			.clear{	clear:both;	}
		&lt;/style&gt;
	&lt;/head&gt;
	&lt;body&gt;
		&lt;div id="container"&gt;
			&lt;strong&gt;Select layout&lt;/strong&gt;
			&lt;select id="layout"&gt;
				&lt;option value="600"&gt;Wide&lt;/option&gt;
				&lt;option value="300"&gt;Narrow&lt;/option&gt;
			&lt;/select&gt;
			&lt;div class="clear"&gt; &lt;/div&gt;
			&lt;div id="tweets"&gt;&lt;/div&gt;
		&lt;/div&gt;
	&lt;/body&gt;
&lt;/html&gt;</pre>
<p style="text-align: left;">
<p style="text-align: left;"><strong>jQuery Code</strong></p>
<p style="text-align: left;">Just before the body tag closes, add path to jQuery library either from your local file system or the Google CDN.</p>
<p style="text-align: left;">
<pre class="brush:js">&lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"&gt;&lt;/script&gt;</pre>
<p>With this we are ready to pull the tweets. Start by defining 2 variables <strong><em>userName</em></strong> and <strong><em>count</em></strong>. Inside document.ready add a change event handler to select box with id <strong>layout</strong>. It will change its width from 600px to 300px on selecting narrow and again back to 600px on selecting wide.</p>
<p>Now call a function <strong>getTweets </strong>and pass user name and number of tweets to it.</p>
<pre class="brush:js">var userName = 'v08i';
var count = 8;
$(document).ready(function()
{
	$('#layout').change(function()
	{
		$('#container').css({ 'width' : $(this).val()+ 'px'});
	});
	getTweets(userName, count);

});</pre>
<p>getTweets function will actually contact the Twitter API and will fetch tweets from there. We will request the response in JSON format from Twitter using jQuery&#8217;s <strong>getJSON </strong>method.</p>
<p>Before we proceed let us talk a bit technical. As you probably know, browsers do not allow cross-domain ajax requests due to security reasons. In this case the example we are creating is at domain <span style="text-decoration: underline;">vijayjoshi.org</span> while the twitter domain is <span style="text-decoration: underline;">api.twitter.com</span>. If both domains were same, a simple AJAX request would have sufficed. To overcome this problem JSONP aka &#8220;JSON with Padding&#8221; is used.</p>
<p>To use JSONP with jQuery, just change the <strong>dataType</strong> parameter from <strong>json</strong> to <strong>jsonp</strong>. Now you do not have to worry about cross domain restriction or anything else. Just define a callback function (showTweets in this example) and you will receive the JSON response there.</p>
<pre class="brush:js">function getTweets(userName, count)
{
	$.getJSON(
		'http://api.twitter.com/1/statuses/user_timeline.json?screen_name=' + userName + '&amp;count='+ count +'&amp;callback=?',
		{},
		showTweets,
		'jsonp'
	);
}</pre>
<p>Now that we have the response, define <strong>showTweets</strong> function, iterate in the results and display them. Here is how.</p>
<pre class="brush:js">function showTweets(tweets)
{
	var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
	var str = '&lt;ul&gt;';
	str+= '&lt;h2&gt;Recent Tweets from ' + userName +'&lt;/h2&gt;';
	var i = 0;
	$.each(tweets, function(index,value)
	{
		if(i == count)	return;
		var dt = new Date(value.created_at);
		str+= '&lt;li&gt;&lt;p&gt;';
		str+= value.text;
		str+= '&lt;/p&gt;';
		str+='&lt;span&gt;';
		str+= dt.getDate() + '-' + months[dt.getMonth()] + '-' + dt.getFullYear();
		str+= ' at ' + dt.getHours() + ':' +dt.getMinutes();
		str+= ' From ' + value.source;
		str+= '&lt;/span&gt;&lt;/li&gt;';
		i++;
	});
	str+= '&lt;/ul&gt;';
	$('#tweets').html(str);
	$('#tweets &gt; ul &gt; li:odd').addClass('odd');
	$('#tweets &gt; ul &gt; li:even').addClass('even');
}</pre>
<p>I have used only some of the values from the JSON response. You can view the full response by typing the following into your browser.</p>
<pre class="brush:as3">http://api.twitter.com/1/statuses/user_timeline.json?screen_name=your_twitter_username&amp;count=10</pre>
<p>With this we are done. Have a look at the demo I have created.</p>
<p style="text-align: center;"><a href="http://vijayjoshi.org/examples/twitter-latest-tweets.html"><img class="size-full wp-image-453 aligncenter" title="View Demo" src="http://www.vijayjoshi.org/wp-content/uploads/demo.png" alt="View Demo" width="180" height="45" /></a></p>
<p>For full source code, just view page source. It&#8217;s all happening on your browser after all.</p>
<p>If you have any questions, let me know in comments.</p>
<div class="shr-publisher-886"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F24%2Fusing-twitter-api-and-jquery-to-display-recent-tweets%2F' data-shr_title='Using+Twitter+API+and+jQuery+to+display+recent+tweets'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2010/12/24/using-twitter-api-and-jquery-to-display-recent-tweets/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Working with XML Documents in PHP and jQuery</title>
		<link>http://www.vijayjoshi.org/2010/12/23/working-with-xml-documents-in-php-and-jquery/</link>
		<comments>http://www.vijayjoshi.org/2010/12/23/working-with-xml-documents-in-php-and-jquery/#comments</comments>
		<pubDate>Thu, 23 Dec 2010 10:17:15 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=881</guid>
		<description><![CDATA[
			
				
			
		
Here is one more sample chapter from my book. It explains reading, writing and editing XML files with PHP and jQuery. Below are the chapter contents.
Loading XML from files and strings using SimpleXML
Accessing elements and attributes using SimpleXML
Searching elements using XPath
Reading an XML using DOM extension
Creating an XML using DOM extension
Modifying an XML using DOM extension
Parsing XML with jQuery

Loading XML ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F23%2Fworking-with-xml-documents-in-php-and-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F23%2Fworking-with-xml-documents-in-php-and-jquery%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Here is one more sample chapter from <a title="PHP jQuery Cookbook" href="http://www.vijayjoshi.org/2010/11/22/guys-i-am-writing-a-book/">my book</a>. It explains reading, writing and editing XML files with PHP and jQuery. Below are the chapter contents.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Loading XML from files and strings using SimpleXML</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Accessing elements and attributes using SimpleXML</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Searching elements using XPath</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Reading an XML using DOM extension</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Creating an XML using DOM extension</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Modifying an XML using DOM extension</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Parsing XML with jQuery</div>
<ul>
<li>Loading XML from files and strings using SimpleXML</li>
<li>Accessing elements and attributes using SimpleXML</li>
<li>Searching elements using XPath</li>
<li>Reading an XML using DOM extension</li>
<li>Creating an XML using DOM extension</li>
<li>Modifying an XML using DOM extension</li>
<li>Parsing XML with jQuery</li>
</ul>
<p>To read the full chapter follow this link - <a title="Working with XML in PHP and jQuery" href="https://www.packtpub.com/article/working-with-xml-documents">https://www.packtpub.com/article/working-with-xml-documents</a></p>
<p>You can also read the chapter on <a title="JSON with PHP and jQuery" href="http://www.vijayjoshi.org/2010/12/20/working-with-json-in-php-and-jquery/">using JSON with PHP and jQuery</a>.</p>
<div class="shr-publisher-881"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F23%2Fworking-with-xml-documents-in-php-and-jquery%2F' data-shr_title='Working+with+XML+Documents+in+PHP+and+jQuery'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2010/12/23/working-with-xml-documents-in-php-and-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Filling a select box using javascript and jQuery</title>
		<link>http://www.vijayjoshi.org/2010/12/21/filling-a-select-box-using-javascript-and-jquery/</link>
		<comments>http://www.vijayjoshi.org/2010/12/21/filling-a-select-box-using-javascript-and-jquery/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 08:25:22 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[IE]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=861</guid>
		<description><![CDATA[
			
				
			
		
innerHTML is commonly used property for setting html content of elements. Though it is not a standard property, even then all browsers support it. It is faster then using DOM methods like createElement and appendChild.
You can use it to set html for almost all elements. In internet explorer there are some exceptions. You cannot set innerHTML for elements of a ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F21%2Ffilling-a-select-box-using-javascript-and-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F21%2Ffilling-a-select-box-using-javascript-and-jquery%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>innerHTML is commonly used property for setting html content of elements. Though it is not a standard property, even then all browsers support it. It is faster then using DOM methods like createElement and appendChild.</p>
<p>You can use it to set html for almost all elements. <strong>In internet explorer there are some exceptions. You cannot set innerHTML for <a title="innerHTML of a table" href="http://www.vijayjoshi.org/2008/07/28/internet-explorer-innerhtml-problem-while-adding-rows-in-table-with-javascript/">elements of a table</a> and <a title="innerHTML of select box" href="http://www.vijayjoshi.org/2008/10/05/setting-innerhtml-of-select-ie-screws-me-again/">select box</a>.</strong></p>
<p>Recently a reader asked me the workaround for setting options inside a select box with the help of javascript or jQuery. In this post I will explain some methods which you can use as an alternate to innerHTML.</p>
<div class="mceTemp mceIEcenter">
<dl id="attachment_453" class="wp-caption aligncenter" style="width: 190px;">
<dt class="wp-caption-dt"><a href="http://www.vijayjoshi.org/examples/fillSelectBox.html"><img class="size-full wp-image-453" title="demo" src="http://www.vijayjoshi.org/wp-content/uploads/demo.png" alt="View Demo" width="180" height="45" /></a></dt>
</dl>
</div>
<p>Here is a html select box.</p>
<pre class="brush:html">&lt;select id="selectBox"&gt;
&lt;/select&gt;</pre>
<p>Now let us look at various options available to us.</p>
<p><span id="more-861"></span></p>
<h3>Using innerHTML</h3>
<p>This is the problem. This method will work in all browsers except IE (i have tested till IE8).</p>
<pre class="brush:js">var select = document.getElementById('selectBox');
var options = '&lt;option&gt;option 1&lt;/option&gt;';
options+= '&lt;option&gt;option 2&lt;/option&gt;';
options+= '&lt;option&gt;option 3&lt;/option&gt;';
select.innerHTML = options;</pre>
<h3>Using DOM &#8211; Works in all browsers</h3>
<pre class="brush:js">var select = document.getElementById('selectBox');
for(var i=0; i&lt;3; i++)
{
	var option = document.createElement('option');
	option.appendChild(document.createTextNode('option' + i));
	select.appendChild(option);
}</pre>
<h3>Using jQuery</h3>
<p>Method 1- This will work in all browsers.</p>
<pre class="brush:js">$('#selectBox').append('&lt;option&gt;an option&lt;/option&gt;');
$('#selectBox').append('&lt;option&gt;another option&lt;/option&gt;');
$('#selectBox').append('&lt;option&gt;yet another option&lt;/option&gt;');</pre>
<p>append method appends the html at the end of an element.</p>
<h3>Using jQuery</h3>
<p>Method 2 &#8211; This will also work in all browsers.</p>
<pre class="brush:js">var options = '&lt;option&gt;option 1&lt;/option&gt;';
options+= '&lt;option&gt;option 2&lt;/option&gt;';
options+= '&lt;option&gt;option 3&lt;/option&gt;';
$('#selectBox').html(options);</pre>
<p>html() method in jQuery can be thought of as a counterpart of the innerHTML property.</p>
<div class="mceTemp mceIEcenter">
<dl id="attachment_453" class="wp-caption aligncenter" style="width: 190px;">
<dt class="wp-caption-dt"><a href="http://www.vijayjoshi.org/examples/fillSelectBox.html"><img class="size-full wp-image-453" title="demo" src="http://www.vijayjoshi.org/wp-content/uploads/demo.png" alt="View Demo" width="180" height="45" /></a></dt>
</dl>
</div>
<p>That is all folks. Hope it helps you. If you know of any other technique, do let me know in comments.</p>
<div class="shr-publisher-861"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F21%2Ffilling-a-select-box-using-javascript-and-jquery%2F' data-shr_title='Filling+a+select+box+using+javascript+and+jQuery'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2010/12/21/filling-a-select-box-using-javascript-and-jquery/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Working with JSON in PHP and jQuery</title>
		<link>http://www.vijayjoshi.org/2010/12/20/working-with-json-in-php-and-jquery/</link>
		<comments>http://www.vijayjoshi.org/2010/12/20/working-with-json-in-php-and-jquery/#comments</comments>
		<pubDate>Mon, 20 Dec 2010 11:56:18 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Resources]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=853</guid>
		<description><![CDATA[
			
				
			
		
I mentioned in a previous post that I was writing a book on PHP and jQuery. Well, after a labor of around 7 months the book is out now. It is available on Packt website as well as Amazon.
Meanwhile, to help you make a decision, a sample chapter from the book is available on Packt website. The chapter is Working ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F20%2Fworking-with-json-in-php-and-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F20%2Fworking-with-json-in-php-and-jquery%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I mentioned in a <a title="PHP jQuery Cookbook" href="http://www.vijayjoshi.org/2010/11/22/guys-i-am-writing-a-book/">previous post</a> that I was writing a book on PHP and jQuery. Well, after a labor of around 7 months the book is out now. It is available on <a title="PHP jQuery Cookbook on Packt" href="http://goo.gl/WlFX">Packt website</a> as well as <a title="PHP jQuery Cookbook on Amazon" href="http://www.amazon.com/PHP-jQuery-Cookbook-Vijay-Joshi/dp/1849512744/">Amazon</a>.</p>
<p>Meanwhile, to help you make a decision, a sample chapter from the book is available on Packt website. The chapter is Working with JSON in PHP and jQuery and it contains 4 articles that explain creating, reading and writing JSON in PHP as well as jQuery.</p>
<p>Below are the topics that this chapter covers:</p>
<ul>
<li>Creating JSON in PHP</li>
<li>Reading JSON in PHP</li>
<li>Catching JSON parsing errors</li>
<li>Accessing data from a JSON in jQuery</li>
</ul>
<p>To read the full chapter, just follow this link <a title="Working with JSON in PHP jQuery" href="http://www.packtpub.com/article/working-json-php-jquery">http://www.packtpub.com/article/working-json-php-jquery</a></p>
<div class="shr-publisher-853"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F20%2Fworking-with-json-in-php-and-jquery%2F' data-shr_title='Working+with+JSON+in+PHP+and+jQuery'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2010/12/20/working-with-json-in-php-and-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating a text rotator with jQuery</title>
		<link>http://www.vijayjoshi.org/2010/12/14/creating-a-text-rotator-with-jquery-2/</link>
		<comments>http://www.vijayjoshi.org/2010/12/14/creating-a-text-rotator-with-jquery-2/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 07:14:25 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=742</guid>
		<description><![CDATA[
			
				
			
		

jQuery is appropriately described as the &#8220;write less, do more&#8221; library. Few lines of code, if written appropriately, can produce wonderful tools or utilities.
In this article we will create a simple text rotator (or banner rotator whatever you want to call it). Simply put, there will be a placeholder which will have multiple quotations written inside it. These quotations will ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F14%2Fcreating-a-text-rotator-with-jquery-2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F14%2Fcreating-a-text-rotator-with-jquery-2%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-770" title="quote" src="http://www.vijayjoshi.org/wp-content/uploads/quote.png" alt="quote" width="536" height="88" /></p>
<p>jQuery is appropriately described as the &#8220;write less, do more&#8221; library. Few lines of code, if written appropriately, can produce wonderful tools or utilities.</p>
<p>In this article we will create a simple text rotator (or banner rotator whatever you want to call it). Simply put, there will be a placeholder which will have multiple quotations written inside it. These quotations will be displayed one by one with a fading effect. Have a look at the demo to see how it will look like.</p>
<div class="mceTemp mceIEcenter">
<dl id="attachment_453" class="wp-caption aligncenter" style="width: 190px;">
<dt class="wp-caption-dt"><a title="Text Rotator" href="http://www.vijayjoshi.org/examples/textRotator.html"><img class="size-full wp-image-453" title="demo" src="http://www.vijayjoshi.org/wp-content/uploads/demo.png" alt="View Demo" width="180" height="45" /></a></dt>
</dl>
</div>
<p>Now that you have seen the demo and you find it interesting enough, here is how to create it.</p>
<p>Write the following html which will create a container div with id <strong><em>quotes</em></strong>. Inside this div, create multiple divs, each of which will hold a quotation and assign a css class <strong><em>textItem</em> </strong>to them.</p>
<p>Except for 2 things, you can style the elements as per your wish. First, div with id <em><strong>quotes</strong> </em>should have position as relative and each <strong><em>textItem</em></strong> should have position set to absolute. <strong>Absolute positioning for quotations will ensure that they are stacked on top of each other</strong>. This way if we fade out a quotation and fade in the next one, it will give desired effect.</p>
<p><span id="more-742"></span></p>
<p>Complete markup will look like the following.</p>
<pre class="brush:html"> &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
 &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
 &lt;head&gt;
&lt;title&gt;jQuery Text Rotator - by Vijay Joshi | vijayjoshi.org&lt;/title&gt;
&lt;style type="text/css"&gt;
 body
 {
   background-color:#BCDFDB;
   color: #025C7F;
   font-family:verdana,arial;
 }
 #quotes
 {
   margin:0;
   padding:100px;
   font-size:20px;
   position:relative;
 }
 .textItem
 {
   position:absolute;
   display:none;
 }
 a
 {
   color:#000;
   font-size:15px;
 }
 &lt;/style&gt;
 &lt;/head&gt;
 &lt;body&gt;
     &lt;div id="quotes"&gt;
         &lt;div&gt;Before turning to those moral and mental aspects of the matter which
present the greatest difficulties, let the inquirer begin by mastering
more elementary problems.
         &lt;/div&gt;

         &lt;div&gt;How often have I said to you that when you have eliminated the
impossible, whatever remains, however improbable, must be the truth?
         &lt;/div&gt;

         &lt;div&gt;It is a capital mistake to theorize before one has data.
Insensibly one begins to twist facts to suit theories, instead of
theories to suit facts.
         &lt;/div&gt;

         &lt;div&gt;We must fall back upon the old axiom that when all other contingencies
fail, whatever remains, however improbable, must be the truth.
         &lt;/div&gt;
     &lt;/div&gt;
 &lt;/body&gt;
&lt;/html&gt;</pre>
<p>Now just before the body tag closes, include jQuery and next to it write the actual code that will put life to our quotations.</p>
<pre class="brush:js">&lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/
jquery/1.4.4/jquery.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
 $(document).ready(function()
 {
     setupRotator();
 });
 function setupRotator()
 {
     if($('.textItem').length &gt; 1)
     {
         $('.textItem:first').addClass('current').fadeIn(1000);
         setInterval('textRotate()', 3000);
     }
 }
     function textRotate()
     {
         var current = $('#quotes &gt; .current');
         if(current.next().length == 0)
         {
             current.removeClass('current').fadeOut(1000);
             $('.textItem:first').addClass('current').fadeIn(1000);
         }
         else
         {
             current.removeClass('current').fadeOut(1000);
             current.next().addClass('current').fadeIn(1000);
         }
     }
&lt;/script&gt;</pre>
<p>First of all, function <strong>setupRotator</strong> is called on document ready. This function will hide all <strong><em>textItem</em> </strong>elements. Then it finds the first <strong><em>textItem</em> </strong>and adds a class <strong><em>current</em> </strong>to it. <strong><em>current</em> </strong>class will help us identify which quotation is currently being displayed. After applying the class <strong><em>current</em> </strong>it uses the <strong><em>fadeIn</em> </strong>function to display the first item.</p>
<p>Now comes the key point. Using JavaScript function <strong><em>setInterval</em></strong>, set a function <strong><em>textRotate()</em></strong> to execute every 3 seconds.</p>
<p>Here is what <strong><em>textRotate</em> </strong>function does.</p>
<ul>
<li>get the quotation with class <strong><em>current</em> </strong>- This will be currently visible element on page</li>
<li>Check if this quotation has any element next to it or not</li>
<li>If not, this means it is the last quotation. Therefore, remove the class <em><strong>current </strong></em>from it and use <em><strong>fadeOut </strong></em>function which will hide it after 1 second. Find the first quotation, apply class current to it and use <strong><em>fadeIn </em></strong>to make it visible</li>
<li>If a quotation is found next to current quotation, remove the class <em><strong>current </strong></em>from it and use <em><strong>fadeOut </strong></em>to hide it. Apply class <strong><em>current </em></strong>to the next element and make it visible using <em><strong>fadeIn</strong></em></li>
</ul>
<p>We have used value 1000 at all places in <em><strong>fadeIn </strong></em>and <em><strong>fadeOut </strong></em>which means the animation will take 1 second to complete, providing the desired effect.</p>
<p><strong> </strong></p>
<div class="mceTemp mceIEcenter">
<dl id="attachment_453" class="wp-caption aligncenter" style="width: 190px;">
<dt class="wp-caption-dt"><a title="Text Rotator" href="http://www.vijayjoshi.org/examples/textRotator.html"><strong><strong><img class="size-full wp-image-453" title="demo" src="http://www.vijayjoshi.org/wp-content/uploads/demo.png" alt="View Demo" width="180" height="45" /></strong> </strong></a></dt>
</dl>
</div>
<p><strong> </strong></p>
<p>Do not forget to view page source for full code.</p>
<p>I will soon convert it to a jQuery plugin so that it becomes easy to use it on pages without any change to code.</p>
<div class="shr-publisher-742"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F14%2Fcreating-a-text-rotator-with-jquery-2%2F' data-shr_title='Creating+a+text+rotator+with+jQuery'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2010/12/14/creating-a-text-rotator-with-jquery-2/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>jQuery: Difference between .each and jQuery.each</title>
		<link>http://www.vijayjoshi.org/2010/11/24/jquery-difference-between-each-and-jquery-each/</link>
		<comments>http://www.vijayjoshi.org/2010/11/24/jquery-difference-between-each-and-jquery-each/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 18:55:49 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=683</guid>
		<description><![CDATA[
			
				
			
		
It can be quite confusing when you have 2 methods in an API with same names. Hopefully, this post will clear up your doubts.
.each is an iterator that is used to iterate over only jQuery objects collection while jQuery.each is a general function for iterating over javascript objects and arrays.
Still confused? Let us look at the usage of both of ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F11%2F24%2Fjquery-difference-between-each-and-jquery-each%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F11%2F24%2Fjquery-difference-between-each-and-jquery-each%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>It can be quite confusing when you have 2 methods in an API with same names. Hopefully, this post will clear up your doubts.</p>
<blockquote><p><em>.each</em> is an iterator that is used to iterate over only jQuery objects collection while <em>jQuery.each</em> is a general function for iterating over javascript objects and arrays.</p></blockquote>
<p>Still confused? Let us look at the usage of both of these with examples.</p>
<p><em><span style="text-decoration: underline;"><strong>.each()</strong></span></em></p>
<p>Consider the following markup.</p>
<pre class="brush:js">
<div id="dv">
<input type="text" value="text box" />
&lt;p&gt;
paragraph element
&lt;/p&gt;
<span>span element</span></div>
</pre>
<p>Suppose we want to find out the tag name of each element present inside this div. In this case we will use <em>.each</em> iterator<br />
<span id="more-683"></span></p>
<pre class="brush:js">$('#dv').children().each(function(index, element)
{
 console.log('element at index ' + index + 'is ' + (this.tagName).toLowerCase();
});</pre>
<pre class="brush:js">//Output
element at index 0 is input
element at index 1 is p
element at index 2 is span</pre>
<p><em>each()</em> function takes 2 parameters, index of current element and the DOM element itself. Therefore, this will refer to the DOM element inside <em>each()</em>. We can get the tag name using <em>tagName</em> property of DOM element.(<a title="jQuery Tag Name" href="http://www.vijayjoshi.org/2010/11/20/jquery-tip-finding-tag-name-of-an-element/">This post explains it in detail</a>). To use the corresponding jQuery object, use <em>$(this)</em></p>
<p><em><span style="text-decoration: underline;"><strong>jQuery.each()</strong></span></em></p>
<p><em>jQuery.each</em> takes 2 parameters. First is the object over which the iteration is to be done and second is the callback function that will execute on each iteration. The callback function provides 2 parameter, first is index of current element(or you can say key in case of objects) in object and second the value at that index.</p>
<p>First, let us iterate over a js array.</p>
<pre class="brush:js">var myArray = [10,20,30,40,50];

jQuery.each(myArray, function(index, value)
{
    console.log('element at index ' + index + ' is ' + value);
});

//Output
element at index 0 is 10
element at index 1 is 20
element at index 2 is 30
element at index 3 is 40
element at index 4 is 50</pre>
<p>Another example using an object</p>
<pre class="brush:js">var myObj = {
"Google" : "http://google.com",
"Reddit" : "http://reddit.com",
"Mashable" : "http://mashable.com"
};
jQuery.each(myObj, function(key, value)
{
    console.log('value for key ' + key + ' is ' + value);
});

//Output
value for key Google is http://google.com
value for key Reddit is http://reddit.com
value for key Mashable is http://mashable.com</pre>
<p>That&#8217;s it. If you still have doubts, let me know in comments.</p>
<div class="shr-publisher-683"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F11%2F24%2Fjquery-difference-between-each-and-jquery-each%2F' data-shr_title='jQuery%3A+Difference+between+.each+and+jQuery.each'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2010/11/24/jquery-difference-between-each-and-jquery-each/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

