<?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>Dev Tips &#124; Become a Better Developer, One Tip at a Time. &#187; Javascript</title>
	<atom:link href="http://dev-tips.com/category/client-side/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://dev-tips.com</link>
	<description>Become a Better Developer, One Tip at a Time.</description>
	<lastBuildDate>Sun, 07 Mar 2010 02:19:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>AJAX and PHP, Building Modern Web Apps &#8211; Book Review</title>
		<link>http://dev-tips.com/featured/ajax-and-php-building-modern-web-apps-book-review</link>
		<comments>http://dev-tips.com/featured/ajax-and-php-building-modern-web-apps-book-review#comments</comments>
		<pubDate>Thu, 28 Jan 2010 21:48:26 +0000</pubDate>
		<dc:creator>Drew Douglass</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[Book Review]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=853</guid>
		<description><![CDATA[As many of you know, I'm a huge fan of reading actual web development books to increase ones skills. Sometimes, you just need to step away from the computer and read an actual physical book. I recently had the pleasure of reading AJAX and PHP: Building Modern Web Applications - Second Edition, and I absolutely [...]]]></description>
			<content:encoded><![CDATA[<p>As many of you know, I'm a huge fan of reading actual web development books to increase ones skills. Sometimes, you just need to step away from the computer and read an actual physical book. I recently had the pleasure of reading <a href='http://www.packtpub.com/ajax-and-php-2nd-edition/mid/050110l77db5?utm_source=dev-tips.com&#038;utm_medium=affiliate&#038;utm_content=blog&#038;utm_campaign=mdb_002002' title='AJAX and PHP Book'>AJAX and PHP: Building Modern Web Applications - Second Edition</a>, and I absolutely loved it. I'm going to take some time today to go over the some of <a href='http://www.packtpub.com/ajax-and-php-2nd-edition/mid/050110l77db5?utm_source=dev-tips.com&#038;utm_medium=affiliate&#038;utm_content=blog&#038;utm_campaign=mdb_002002'>the book</a>, and what I feel it has to offer the average reader.</p>
<p><span id="more-853"></span><br />
<a href="http://www.packtpub.com/ajax-and-php-2nd-edition/mid/050110l77db5?utm_source=dev-tips.com&amp;utm_medium=affiliate&amp;utm_content=blog&amp;utm_campaign=mdb_002002"><img src="http://dev-tips.com/wp-content/uploads/2010/01/ajax-php-review.jpg" alt="" title="ajax-php-review" width="605" height="220" class="aligncenter size-full wp-image-866" /></a></p>
<h2>Review Overview</h2>
<ul>
<li>Book Summary</li>
<li>Who is this book for?</li>
<li>Subject Matter</li>
<li> Notable content/features</li>
<li>Final Thoughts</li>
</ul>
<h2>Book Summary</h2>
<p>The main focus of <a href='http://www.packtpub.com/ajax-and-php-2nd-edition/mid/050110l77db5?utm_source=dev-tips.com&#038;utm_medium=affiliate&#038;utm_content=blog&#038;utm_campaign=mdb_002002' title='AJAX and PHP: Building Modern Web Apps'>AJAX and PHP: Building Modern Web Apps</a> is to get you up and running using raw Javascript and php to build practical and useful applications. I was happy to see the book mentions Javascript libraries, but really teaches the reader how to do things with plain old Javacript while accounting for all browsers. It was actually fun learning how to create your own AJAX cross browse compatible objects, which is something I never though I'd say.</p>
<p>To quote the books description and give you a better idea of the subject matter:</p>
<p>
<blockquote>This book is a step-by-step, example-driven AJAX tutorial, featuring complete case studies. Each chapter contains a friendly mix of theory and practice, so that your journey through the book will be pleasant, yet efficient. You’ll be coding your first AJAX application at the end of the first chapter, and with each new chapter you’ll develop increasingly complex AJAX applications featuring advanced techniques and coding patterns.</p></blockquote>
<h2>Who is this book for?</h2>
<p>In my opinion this book is great for beginners to web development, intermediate web developers looking to polish their AJAX and php skills, or advanced users who may have not had much experience using raw Javascript in web applications.</p>
<p>Anyone wanting to learn how php and Javascript can integrate asynchronosuly together will probably find this book behooving.</p>
<h2>Subject Matter</h2>
<p>I can't reveal all the details, but there are some seriously awesome applications and tutorials used in this book. </p>
<p>You are first introduced and walked through the basics of everything you'll need to get started, there is also a great primer on Javascript and even OOP style of Javascript, which is a nice bonus.</p>
<p>After that, you jump right in to building example AJAX applications, taking advantage of different web services and API.</p>
<p>Both XML and JSON formats are covered, which is essential.</p>
<h2>Notable Content/Features</h2>
<p>The section dealing with JSON vs XML is just awesome no matter which side of the fence you happen to stand on. Truth is, both data formats are in wide use, so it's helpful to know how to use them both when it relate to AJAX and PHP.</p>
<p>Another feature of <a href='http://www.packtpub.com/ajax-and-php-2nd-edition/mid/050110l77db5?utm_source=dev-tips.com&#038;utm_medium=affiliate&#038;utm_content=blog&#038;utm_campaign=mdb_002002'>the book</a> I really enjoyed was the bonus on "Design Patterns" where common JS and PHP design patterns are evaluated and explained, it's very helpful for anyone trying to improve their application workflow.</p>
<p>Lastly, I'm very happy with how thorough of a job the authors did when it came to handling and dealing with cross browser issues. This isn't the most fun thing in the world, but any developer knows it's vital that their app work seamlessly across all common browsers.</p>
<h2>Final Thoughts</h2>
<p>As with nearly every single book from Packt, <a href='http://www.packtpub.com/ajax-and-php-2nd-edition/mid/050110l77db5?utm_source=dev-tips.com&#038;utm_medium=affiliate&#038;utm_content=blog&#038;utm_campaign=mdb_002002' title='AJAX and PHP'>AJAX and PHP: Building Modern Web Applications</a> is absolutely worth the price. It's a book to keep on your shelf when you're done reading to resort back to anytime you want to get your hands dirty with AJAX, and want things explained in a clear and precise manner.</p>
<h2>As Always...</h2>
<p>As always, I like to show all of you that I do in fact read all of these books I talk about and review, so here is my wonderfully extremely good looking self rocking the book:</p>
<div id="attachment_859" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.packtpub.com/ajax-and-php-2nd-edition/mid/050110l77db5?utm_source=dev-tips.com&#038;utm_medium=affiliate&#038;utm_content=blog&#038;utm_campaign=mdb_002002"><img src="http://dev-tips.com/wp-content/uploads/2010/01/AJAXandPHP-Drew-e1264713791250.jpg" alt="" title="AJAXandPHP-Drew" width="500" height="375" class="size-full wp-image-859" /></a><p class="wp-caption-text">Drew approves; he needs a haircut too!</p></div>
<h2>Get It Now!</h2>
<div><a href='http://www.packtpub.com/ajax-and-php-2nd-edition/mid/050110l77db5?utm_source=dev-tips.com&#038;utm_medium=affiliate&#038;utm_content=blog&#038;utm_campaign=mdb_002002'><img src='http://dev-tips.com/wp-content/uploads/2010/01/ajax_php_ss.png' alt='' /></a></div>
<p>You can <a href='http://www.packtpub.com/ajax-and-php-2nd-edition/mid/050110l77db5?utm_source=dev-tips.com&#038;utm_medium=affiliate&#038;utm_content=blog&#038;utm_campaign=mdb_002002' title='Get AJAX and PHP the book!'>pick up the book directly from PacktPubs</a> website and get started with AJAX and PHP today <img src='http://dev-tips.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/ajax-and-php-building-modern-web-apps-book-review/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Awesome radio button grouping with jQuery</title>
		<link>http://dev-tips.com/featured/awesome-radio-button-grouping-with-jquery</link>
		<comments>http://dev-tips.com/featured/awesome-radio-button-grouping-with-jquery#comments</comments>
		<pubDate>Sun, 20 Dec 2009 02:21:13 +0000</pubDate>
		<dc:creator>Barry Roodt</dc:creator>
				<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[grouping]]></category>
		<category><![CDATA[radio]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=679</guid>
		<description><![CDATA[I was asked to do something rather interesting with some radio button inputs the other day. I haven't come across this particular problem before and google didn't return anything helpful, so I decided to share what I came up with. Live Demo First, the scenario We have a standard form with 4 radio button groups. [...]]]></description>
			<content:encoded><![CDATA[<p>I was asked to do something rather interesting with some radio button inputs the other day. I haven't come across this particular problem before and google didn't return anything helpful, so I decided to share what I came up with.</p>
<p><span id="more-679"></span></p>
<h2 class='box demo'><a target='_blank' href='http://flexidev.co.za/dev/code/advancedradio/' title='View Demo'>Live Demo</a></h2>
<h2>First, the scenario</h2>
<p>We have a standard form with 4 radio button groups. Each group has 4 radio buttons labeled from<em> "1" </em>to <em>"4"</em>. Now, when the user selects<em> "option 1"</em> in <em>"group 1"</em>, all the remaining <em>"option 1"</em> items need to be disabled. To see an example in action, <a title="Advanced Radio demo" href="http://flexidev.co.za/dev/code/advancedradio/" target="_blank">you can view the demo here</a>.</p>
<h2>The problem</h2>
<p>When I first started, I thought that it's simply a matter of giving each <em>"option"</em> (regardless of group) a common class name - then just disabling all other options with the same class name. That works, to a point, but what if the user changes his mind and selects another option ? Now I had to find all previously disabled options, re-enable them and start all over again.</p>
<h2>The solution</h2>
<p>Essentially what I came up with was a basic nested loop to handle setting and unsetting the relevant <em>"disabled"</em> attributes. To achieve this, first we assign all <em>"option 1"</em> a class of <em>"number1"</em>, <em>"option 2"</em> a class of <em>"number2"</em> and so on.</p>
<p>Next, we run a basic <strong><em>for loop</em></strong>, and go through each <em>"number"</em> class (i.e. number1 to number4). For each class, we call a function. Inside this function is another loop - this time iterating over each radio button assigned the current class name. Using this loop, we remove any <em>"disabled" </em>attributes which may have been assigned previously.</p>
<p>We also find out which item in that group is currently selected (if any) - this is so we can run a second loop to disable all those options not currently selected. Confused ? Now might be a good time to go through the code.</p>
<h2>The code</h2>
<pre class="brush: js">
$(function(){
		// fire our code when a radio button has been selected
		$(&quot;input[type=radio]&quot;).change(function(){
			var name = $(this).attr(&quot;name&quot;); // get the current button&#039;s group name
			$(&quot;input[name=&quot;+name+&quot;]&quot;).removeAttr(&quot;selected&quot;); // first we deselect &quot;all&quot; radio buttons within the same group
			$(this).attr(&quot;selected&quot;,&quot;selected&quot;); // make sure our currently &quot;changed&quot; button is selected
			for(i=1;i&lt;=4;i++){ // go through the 4 radio classes
				processRadio(&quot;.radio&quot;+i);
			}
		});
		/**
			Loops through each item with same &quot;class&quot; name and disables/enables where appropriate
		**/
		function processRadio(myclass){
			var empty;
			var id = &quot;&quot;;
			var buttons = $(myclass); // read all buttons with the specified class name into a jQuery object
			buttons.each(function(){ // loop through each item
				var me = $(this);
				var isSelected = me.attr(&quot;selected&quot;); // bool value, based on whether the &quot;selected&quot; attribute is present or not
				me.removeAttr(&quot;disabled&quot;); // clear the disabled attribute if present
				me.siblings(&quot;label&quot;).removeClass(&quot;disabled&quot;); // same with the associated label element
				if (isSelected != empty &amp;amp;&amp;amp; isSelected != &quot;&quot;){
					id = $(this).attr(&quot;id&quot;); // set our tmp id var to our currently selected item
				}
			});
			// make sure we have an id, otherwise we&#039;ll get an error
			if (id != empty &amp;amp;&amp;amp; id != &quot;&quot;){
				buttons.each(function(){ // loop through each radio button once again
					if ($(this).attr(&quot;id&quot;) != id){ // set the disabled attributes if id attribute doesn&#039;t match our tmp id var
						$(this).attr(&quot;disabled&quot;, &quot;disabled&quot;).siblings(&quot;label&quot;).addClass(&quot;disabled&quot;);
					}
				});
			}
		}

	});
</pre>
<p>I&#39;ve commented as best I could, which hopefully makes more sense than my rambling above. Once again, there is a <a title="Advanced Radio demo" href="http://flexidev.co.za/dev/code/advancedradio/" target="_blank">working demo available</a> for you to play with. Be sure to have a look at the markup as well, might clear up a few questions.</p>
<p>I strongly suspect that there's a more efficient method for achieving the same result - so if you have a better suggestion, tweak or link please let me know - I'd greatly appreciate it.</p>
<h2 class='box demo'><a href='http://flexidev.co.za/dev/code/advancedradio/' title='View Demo'>Live Demo</a></h2>
<h2>Editors Note - PHP Book Giveaway</h2>
<p>I'll be announcing the winner for the <a><em>PHP For Absolute Beginners</em> book giveaway</a> on monday, so now is your last second chance to get your comment in for a chance to win. <a href='http://dev-tips.com/featured/php-for-absolute-beginners-reviewed-giveaway'>See here for more details and to enter.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/awesome-radio-button-grouping-with-jquery/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Link Nudge jQuery Plugin</title>
		<link>http://dev-tips.com/featured/link-nudge-jquery-plugin</link>
		<comments>http://dev-tips.com/featured/link-nudge-jquery-plugin#comments</comments>
		<pubDate>Wed, 05 Aug 2009 21:06:02 +0000</pubDate>
		<dc:creator>Drew Douglass</dc:creator>
				<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Downloads]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=499</guid>
		<description><![CDATA[I think it was David Walsh who first showed me the idea of link nudging using jQuery. You can see on the sidebar we also use this technique. I haven't seen a plugin made to do this yet (as it is really simple) so I figured this would be perfect for a quick jQuery plugin [...]]]></description>
			<content:encoded><![CDATA[<p>I think it was <a href='http://davidwalsh.name/jquery-link-nudging'>David Walsh who first showed me</a> the idea of link nudging using jQuery. You can see on the sidebar we also use this technique. I haven't seen a plugin made to do this yet (as it is really simple) so I figured this would be perfect for a quick jQuery plugin tutorial. You can download the plugin and/or view the demo below.</p>
<p><span id="more-499"></span></p>
<h2 class='box demo'><a href='http://dev-tips.com/demo/link_nudge.html' title='Link Nudge Demo'>View Demo</a></h2>
<div class='download_orange'><a class="downloadlink" href="http://dev-tips.com/wp-content/plugins/download-monitor/download.php?id=3" title="Version 1.0 downloaded 526 times" >jQuery Link Nudge Plugin (526) - 19.9 KB</a></div>
<p><strong>Authors Note:</strong><em>This plugin has now been given the name of NudgeIt and has had a lot of new features added! Please see the two updates at the bottom of this page for more information.</em></p>
<h2>The Plugin Javascript</h2>
<p>Creating the plugin is simple and is as easy as creating any other jQuery plugin. I'll try to comment the source code some so you can get an idea of how it all works.</p>
<p></p><p><strong><a href='http://snipplr.com/view/17929/jquery-link-nudge-plugin'>jQuery Link Nudge Plugin</a></strong><br/><small>Posted by <a href='http://snipplr.com/users/DrewDouglass'>DrewDouglass</a> on August 5th, 2009</small><br/><small>Plugin Source.</small></p><div class='code' style='border: 1px dotted; overflow: auto; white-space:nowrap;'><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>$<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//Define the plugin, named 'linkNudge' </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $.<span style="color: #006600;">fn</span>.<span style="color: #006600;">linkNudge</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>params<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//set default parameters </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; params = $.<span style="color: #006600;">extend</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; padding: <span style="color: #CC0000;">20</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elapseTime: <span style="color: #CC0000;">300</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returnPadding: <span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#125;</span>, params<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//Traverse every node passed </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//Define this as a single object </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> $t = $<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//Proceed to nudge on hover </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $t.<span style="color: #006600;">hover</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $t.<span style="color: #000066;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">css</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'cursor'</span>, <span style="color: #3366CC;">'pointer'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">animate</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>paddingLeft: params.<span style="color: #006600;">padding</span><span style="color: #66cc66;">&#125;</span>, params.<span style="color: #006600;">elapseTime</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $t.<span style="color: #000066;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">animate</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>paddingLeft: params.<span style="color: #006600;">returnPadding</span><span style="color: #66cc66;">&#125;</span>, params.<span style="color: #006600;">elapseTime</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>;<span style="color: #009900; font-style: italic;">//Allow for chaining.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span>jQuery<span style="color: #66cc66;">&#41;</span>;</div><p></p>
<h2>Usage</h2>
<pre class="brush: js">
$(function(){
		$(&#039;ul li:even&#039;).linkNudge({
			elapseTime: 500
		}).css(&#039;list-style-type&#039;, &#039;circle&#039;);//Plugin allows for chaining, as seen with the css call.
	});
</pre>
<h2>Documentation</h2>
<p>To use the plugin, simply include the plugin and jQuery library on your page and make a call to the <code>linkNudge</code> function. You can include three optional parameters, as discussed below.</p>
<ol>
<li><strong>padding</strong> - Allows you to set how far the link should be nudged. Defaults to 20px.</li>
<li><strong>elapseTime</strong> - The time, in milliseconds, over which the nudge should occur. Default to 300.</li>
<li><strong>returnPadding</strong> - Optional padding to return to when the element is no longer being hovered. Defaults to 0.</li>
<h2>Terms of Use</h2>
<p>You can't sell it. Otherwise, use it how you would like in your projects, a credit to this page in the notes or documentation would be appreciated. Donations even more so.</p>
<h2 class='box demo'><a href='http://dev-tips.com/demo/link_nudge.html' title='Link Nudge Demo'>View Demo</a></h2>
<div class='download_orange'><a class="downloadlink" href="http://dev-tips.com/wp-content/plugins/download-monitor/download.php?id=3" title="Version 1.0 downloaded 526 times" >jQuery Link Nudge Plugin (526) - 19.9 KB</a></div>
<h2>Feed Me</h2>
<p>If you have used or enjoy this plugin, I urge you to consider making a small donation so I can buy some Chinese food.</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="7298669">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"><br />
</form>
<h2><strong>Update:</strong></h2>
<p>David Walsh has modified the flexibility of the plugin in a <a href='http://davidwalsh.name/jquery-link-nudge'>new post on his blog</a>. I encourage all of you to give it a look and download and see how they differ. You can find <a href='http://davidwalsh.name/jquery-link-nudge'>Davids plugin on his website</a>. Thanks for adding on to and improving the plugin David!</p>
<h2><strong>Update Two!</strong></h2>
<p>David and I have decided to collaborate on this plugin and host it on a <a href='http://github.com/DrewDouglass/NudgeIt'>GitHub</a> so everyone can easily keep track of any updates or changes. We are now also calling the plugin, quite appropriately, <strong>NudgeIt</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/link-nudge-jquery-plugin/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>CSS Tip: How to Make Circles Without Images</title>
		<link>http://dev-tips.com/featured/css-tip-how-to-make-ircles-without-images</link>
		<comments>http://dev-tips.com/featured/css-tip-how-to-make-ircles-without-images#comments</comments>
		<pubDate>Mon, 04 May 2009 02:53:28 +0000</pubDate>
		<dc:creator>Vasili</dc:creator>
				<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=403</guid>
		<description><![CDATA[About a month ago, Jeffery Way posted an article about creating shapes with pure CSS, no images added. I've been using the CSS3 property of border radius a lot in a design I've been working on and thought, "why can't I use this to make circles?" Today, I'll show you how to make your very [...]]]></description>
			<content:encoded><![CDATA[<p>About a month ago, <a href="http://net.tutsplus.com/videos/screencasts/fun-with-css-shapes/">Jeffery Way</a> posted an article about creating shapes with pure CSS, no images added. I've been using the CSS3 property of border radius a lot in a design I've been working on and thought, "why can't I use this to make circles?" Today, I'll show you how to make your very own CSS circles. In addition, we will use our new knowledge to create a simple jQuery plugin!</p>
<p><span id="more-403"></span></p>
<h2 class='box demo'><a href='http://dev-tips.com/demo/css3_circles.html' title='CSS 3 Circles Demo' target='_blank'>View Demo</a></h2>
<h3>Structure, structure, structure!</h3>
<p>How are we suppose to make a circle without any HTML to style? Because this is just a simple shape, I'll be using an "empty" span tab — I've just put &amp;nbsp; into it.</p>
<pre class="brush: html">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;

&lt;title&gt;CSS Circle&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
* {
margin: 0;
padding: 0;
}
body {
margin: 1in;
}
.circle {
/* Everything else goes here. */
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;span class=&quot;circle&quot;&gt;&amp;amp;amp;nbsp;&lt;/span&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>I'll be using inline CSS because this is just a demo, but if this were for a project you'd probably want to put it in an external style sheet. I've also reset the margins and padding, then gave the body a one inch margin to push our circle away from the sides of the page.</p>
<h3>Basic Styles</h3>
<p>For now, I'll give the circle a background of #333 just so we can see it. You'll also want to give it the same height and width, this is the length of the diameter. The size doesn't really matter just make sure it's <strong>en even number</strong>.</p>
<pre class="brush: css">
.circle {
display: block;
width: 80px;
height: 80px;
background: #333;
}
</pre>
<p><em>Note: If you're using an inline element (like a span tag), you'll want to give the element a display of "block". If you don't know if your element is a block level element or not, just load the file in a web browser and if it's height and width look larger than 1px it is.</em></p>
<h3>Circles Are Really Made With CSS3</h3>
<p>What really gives this circle its arcs is CSS3's <a href="http://www.css3.info/preview/rounded-border/">-moz-border-radius and -webkit-border-radius</a> properties. What we're going to have to do is give the border radius a value of <strong>half the height/width</strong>; this is the radius of the circle. For my example, I've used 80px for the height and width so I'll set the border radius to 40px.</p>
<pre class="brush: css">
.circle {
display: block;
display: block;
width: 80px;
height: 80px;
background: #333;
-moz-border-radius: 40px;
-webkit-border-radius: 40px;
}
</pre>
<h3>Conclusion</h3>
<p>CSS3 is a very powerful tool to know how to use. Just make sure you don't base your entire website around it because not every browser supports it yet. However, if you can get the effect in certain browsers and still have you're design looking okay in other browsers, I think it's fine to use browser specific styles.</p>
<h3>Create a jQuery Plugin For Our Circles</h3>
<p>You can also take this a step further by making it into a jQuery plugin.</p>
<pre class="brush: js">
(function($){

	$.fn.jCircle = function(options) {
		var defaults = {
			size: 40
		},
			settings = $.extend({}, defaults, options);

		settings.size = parseInt(settings.size) || 40;
		settings.radius = (settings.size/2) + &#039;px&#039;;

		return this.each(function(){
			var $this = $(this);

			$this.css({
				display: &#039;block&#039;,
				width: settings.size + &#039;px&#039;,
				height: settings.size + &#039;px&#039;
			});

			$this.css(&#039;-moz-border-radius&#039;, settings.radius);
			$this.css(&#039;-webkit-border-radius&#039;, settings.radius);
		});
	}

})(jQuery);
</pre>
<h2 class='box demo'><a href='http://dev-tips.com/demo/css3_circles.html' title='CSS 3 Circles Demo' target='_blank'>View Demo</a></h2>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/css-tip-how-to-make-ircles-without-images/feed</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Javascript Tip: Easy Fading Using jQuery</title>
		<link>http://dev-tips.com/featured/javascript-tip-easy-fading-using-jquery</link>
		<comments>http://dev-tips.com/featured/javascript-tip-easy-fading-using-jquery#comments</comments>
		<pubDate>Thu, 30 Apr 2009 22:29:49 +0000</pubDate>
		<dc:creator>John Bloomfield</dc:creator>
				<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=365</guid>
		<description><![CDATA[Whilst working on a project recently I came across a need for us to show a selection of images depending on their type and when a link to them is clicked. I decided to use jQuery as it saves a lot of time as most of the work is done for you. I will step [...]]]></description>
			<content:encoded><![CDATA[<p>Whilst working on a project recently I came across a need for us to show a selection of images depending on their type and when a link to them is clicked. I decided to use jQuery as it saves a lot of time as most of the work is done for you. I will step through the code so you can see how I did it.
</p>
<p><span id="more-365"></span></p>
<h3><a href='http://dev-tips.com/demo/fading/' target='_blank'>View Demo</a></h3>
<p>As with any jQuery, we are required to use the following line to tell our jQuery code to run as soon as DOM is ready rather than when the page has finished loading.</p>
<pre class="brush: js">
$(document).ready(function(){
</pre>
<p>The next line detects any click from a link inside the div with an id of “links”</p>
<pre class="brush: js">$(&#039;#links a&#039;).click(function(){</pre>
<p>Once a link has been clicked any attribute from that link is accessible through $(this), so the next line sets up a new variable called “color” and takes the “rel” attribute from the tag and puts it into our new variable.</p>
<pre class="brush: js">var color = $(this).attr(&#039;rel&#039;);</pre>
<p>Once we know which colour link has been clicked we can then fade out all images that have a different colour and fade in the colour that has been clicked.</p>
<pre class="brush: js">
$(&#039;#tiles div.tile:not(.&#039; + color + &#039;) img&#039;).fadeTo(&quot;slow&quot;, 0.3);
$(&#039;#tiles div.&#039; + color + &#039; img&#039;).fadeTo(&quot;slow&quot;, 1);
</pre>
<p>To finish off we need to close our function brackets. You will notice there is a “return false;”. This is to stop the link actually activating the href attribute and basically overriding it so we can do our magic. This becomes useful when users don’t have Javascript activated in there browser, you can make the link work as normal. Unfortunately, you would need to create separate pages with different colours highlighted instead. (sigh!)</p>
<p>So, to sum up I have put all the code below and you will need to remember to include the latest jQuery Javascript file from <a href='http://jquery.com'>www.jquery.com</a><br />
All the HTML you can grab from the source of the demo page.</p>
<h2>Final Code</h2>
<pre class="brush: js">
$(document).ready(function(){
   $(&#039;#links a&#039;).click(function(){
      var color = $(this).attr(&#039;rel&#039;);
      $(&#039;#tiles div.tile:not(.&#039; + color + &#039;) img&#039;).fadeTo(&quot;slow&quot;, 0.3);
      $(&#039;#tiles div.&#039; + color + &#039; img&#039;).fadeTo(&quot;slow&quot;, 1);
   });
   return false;
});
</pre>
<p>Hopefully, this will be useful to someone. Have fun!</p>
<h3><a href='http://dev-tips.com/demo/fading/' target='_blank'>View the Demo</a></h3>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/javascript-tip-easy-fading-using-jquery/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How to validate Date of Birth with jQuery</title>
		<link>http://dev-tips.com/featured/how-to-validate-date-of-birth-with-jquery</link>
		<comments>http://dev-tips.com/featured/how-to-validate-date-of-birth-with-jquery#comments</comments>
		<pubDate>Tue, 10 Mar 2009 00:38:13 +0000</pubDate>
		<dc:creator>Barry Roodt</dc:creator>
				<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=261</guid>
		<description><![CDATA[In a recent project I had to implement what's commonly referred to as a Legal Drinking Age (LDA) page. Basically what needs to happen is that the user has to enter their date of birth and thus 'confirm' that they are of a legal drinking age for their respective country. You can view an example [...]]]></description>
			<content:encoded><![CDATA[<p>In a recent project I had to implement what's commonly referred to as a Legal Drinking Age (LDA) page. Basically what needs to happen is that the user has to enter their date of birth and thus 'confirm' that they are of a legal drinking age for their respective country. <a href="http://www.mgstreetdanceafrica.com" title="Malta Guinness Streetdance Africa">You can view an example of just such a page here</a>.</p>
<p>This brought me to an interesting requirement - the user needs to enter their birth of date (in this case via 3 select boxes), their age then needs to be calculated from the entered date and they are either granted, or denied access based on the result.</p>
<p><span id="more-261"></span></p>
<p>Interestingly enough, after having a quick look around I hadn't been able to find any similar example, so I had to come up with something myself. The following code is my solution:</p>
<pre class="brush: js">
$(&quot;#lda-form&quot;).submit(function(){
var day = $(&quot;#day&quot;).val();
var month = $(&quot;#month&quot;).val();
var year = $(&quot;#year&quot;).val();
var age = 18;

var mydate = new Date();
mydate.setFullYear(year, month-1, day);

var currdate = new Date();
currdate.setFullYear(currdate.getFullYear() - age);
if ((currdate - mydate) &lt; 0){
alert(&quot;Sorry, only persons over the age of &quot; + age + &quot; may enter this site&quot;);
return false;
}
return true;
});
</pre>
<p>First, we get the relevant entered date values - the <strong><em>"day"</em></strong>, <strong><em>"month"</em></strong> and <strong><em>"year"</em></strong>. I've also added an <strong><em>"age"</em></strong> var so that this can be easily edited if necessary - the current value is set to 18.</p>
<p>Next we create a Date object and call it <strong><em>"mydate"</em></strong>. We then use the object's <strong><em>"setFullYear"</em></strong> method to set the value of <strong><em>"mydate"</em></strong> to the user's entered birth date. <a title="Javascript setFullYear method" href="http://www.w3schools.com/jsref/jsref_setFullYear.asp">You can view more information about this method here</a>. The only thing to notice here is that we have subtract 1 from the <strong><em>"month"</em></strong> value as it's 0 indexed.</p>
<p>Now that we have the user's birth date sorted, we then create another Date object and call it <strong><em>"currdate"</em></strong>. The default value for <strong><em>"currdate"</em></strong> is the current date. We then set "currdate" to whatever the current date is minus our <strong><em>"age"</em></strong> value - i.e. Today - 18 years. Once again, we use the <strong><em>"setFullYear"</em></strong> method to set the date. However, to get the current date in a useable format, we use the <strong><em>"getFullYear"</em></strong> method and THEN subtract 18 from the resulting value. So to do this we use <strong><em>"currdate.getFullYear() - age"</em></strong>.</p>
<p>Once we have the date of 18 years ago and the user's birth date, both in the same format, it's simply a matter of making sure that the required date minus the birth date isn't greater than 0. If so, we output an alert to inform the user then return <strong><em>"false"</em></strong> to make sure that the form doesn't get submitted.</p>
<p>Pretty straightforward.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/how-to-validate-date-of-birth-with-jquery/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>PHP Tip: Add Custom Google Search Results to Your Site with PHP</title>
		<link>http://dev-tips.com/featured/php-tip-add-custom-google-search-results-to-your-site-with-php</link>
		<comments>http://dev-tips.com/featured/php-tip-add-custom-google-search-results-to-your-site-with-php#comments</comments>
		<pubDate>Fri, 16 Jan 2009 23:06:25 +0000</pubDate>
		<dc:creator>Brian Cray</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Server Side]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=96</guid>
		<description><![CDATA[Have you ever wanted to integrate a custom google search on your site, and style it to your liking? Today, one of our new Dev-Tips author Brian Cray will take you through adding custom google search results to your site with php. What you need Quickly... Mike Migurski's PHP JSON decoder allow_url_fopen set to On [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever wanted to integrate a custom google search on your site, and style it to your liking? Today, one of our new Dev-Tips author <a href="http://twitter.com/briancray">Brian Cray</a> will take you through adding custom google search results to your site with php.</p>
<p><span id="more-96"></span></p>
<h3>What you need</h3>
<p>Quickly...</p>
<ul>
<li><a href="http://mike.teczno.com/">Mike Migurski</a>'s PHP <a href="http://mike.teczno.com/JSON/JSON.phps">JSON decoder</a></li>
<li><code>allow_url_fopen</code> set to <code>On</code> in your PHP.INI (many hosts have this on by default)</li>
<li>A desire to learn to be even more awesome than you already are</li>
</ul>
<p>You'll end up with 2 files to make things work: search.php that shows a search form and results and querygoogle.php that pulls search results from Google. Put the CSS used in this tutorial wherever you want... if you want it.</p>
<h3>How will this make your life better?</h3>
<p>Being the awesome Web developer/designer/jack-of-all-tradeser you are and your clients know you are, you receive frequent requests to add a "little search box" as a part of your client's Web site. What follows is a twitch you disguise as a sneeze because you know you haven't got a solid easy-to-impliment custom solution that the client won't groan at.</p>
<p>But that'll all change now. Armed with a little PHP wizardry, we can turn you into a star. This is a <em>ridiculously</em> easy to implement solution for adding CSS-able custom results straight from Google to your client's Web site. And, we'll do it all in 3+1 easy steps. (note: please read <a href="http://code.google.com/apis/ajaxsearch/terms.html">Google's Terms of Use</a>).</p>
<h3>Step 1: The search form/page - search.php</h3>
<p>Since computers can't yet read minds, we'll have to create a simple search form that includes a text field for the search query and a search button. This should be pretty ho-hum to you, but it's important nonetheless.</p>
<p>Notice the form posts to querygoogle.php. We'll create that script in step 2.</p>
<pre class="brush: html">
&lt;form method=&quot;post&quot; action=&quot;querygoogle.php&quot;&gt;
&lt;label for=&quot;searchquery&quot;&gt;&lt;span class=&quot;caption&quot;&gt;Search this site&lt;/span&gt; &lt;input type=&quot;text&quot; size=&quot;20&quot; maxlength=&quot;255&quot; title=&quot;Enter your keywords and click the search button&quot; name=&quot;searchquery&quot; /&gt;&lt;/label&gt; &lt;input type=&quot;submit&quot; value=&quot;Search&quot; /&gt;
&lt;/form&gt;
</pre>
<p>Yeah baby! We've created a simple search form ready for any daunting search challenge. Let's create the real muscle be your custom search engine, the famed querygoogle.php.</p>
<h3>Step 2: The script to query Google - querygoogle.php</h3>
<p>Now the fun stuff you've been skip scrolling to see (I know your scanning tendancies!). I wrote this PHP script to take advantage of <a href="http://code.google.com/apis/ajaxsearch/">Google's AJAX Search API</a> to provide a transparent, usable, branded experience to end-users. My customers were happy, and yours will be too. Save this PHP as querygoogle.php.</p>
<p>Here's what the code is doing:</p>
<ol>
<li>Includes the JSON library</li>
<li>Sets up the URL that you will give you Google's search results. The URL includes your domain to make it a site specific search and the user's search query. The search uses Google's "site:domain.com keywords" search syntax</li>
<li>Uses <a href="http://us.php.net/fopen">fopen</a> and <a href="http://us.php.net/fread">fread</a> to grab the JSON that results from a call to Google</li>
<li>Decodes the JSON into a PHP object with Mike's JSON library</li>
<li>Iterates through the object, creating custom HTML-formatted results</li>
<li>Sets a session variable that contains the custom HTML-formatted results to send to your custom results page</li>
<li>Uses <a href="http://us2.php.net/header">PHP's header function</a> to send the browser to your custom results page</li>
</ol>
<pre class="brush: php">
&lt;?php
session_start();

// if you use an Mike Migurski&#039;s JSON library, include it like I did
require_once(&#039;JSON.phps&#039;);

// Here&#039;s the Google AJAX Search API url for curl. It uses Google Search&#039;s site:www.yourdomain.com syntax to search in a specific site. I used $_SERVER[&#039;HTTP_HOST&#039;] to find my domain automatically. Change $_POST[&#039;searchquery&#039;] to your posted search query

$url = &#039;http://ajax.googleapis.com/ajax/services/search/web?rsz=large&amp;v=1.0&amp;q=&#039; . urlencode(&#039;site:&#039; . $_SERVER[&#039;HTTP_HOST&#039;] . &#039; &#039; . $_POST[&#039;searchquery&#039;]);

// use fopen and fread to pull Google&#039;s search results

$handle = fopen($url, &#039;rb&#039;);
$body = &#039;&#039;;
while (!feof($handle)) {
$body .= fread($handle, 8192);
}
fclose($handle);

// now $body is the JSON encoded results. We need to decode them.

$json = new Services_JSON();
$json = $json-&gt;decode($body);

// now $json is an object of Google&#039;s search results and we need to iterate through it.

foreach($json-&gt;responseData-&gt;results as $searchresult)
{
if($searchresult-&gt;GsearchResultClass == &#039;GwebSearch&#039;)
{
$formattedresults .= &#039;
&lt;div class=&quot;searchresult&quot;&gt;
&lt;h3&gt;&lt;a href=&quot;&#039; . $searchresult-&gt;unescapedUrl . &#039;&quot;&gt;&#039; . $searchresult-&gt;titleNoFormatting . &#039;&lt;/a&gt;&lt;/h3&gt;
&lt;p class=&quot;resultdesc&quot;&gt;&#039; . $searchresult-&gt;content . &#039;&lt;/p&gt;
&lt;p class=&quot;resulturl&quot;&gt;&#039; . $searchresult-&gt;visibleUrl . &#039;&lt;/p&gt;
&lt;/div&gt;&#039;;
}
}

$_SESSION[&#039;googleresults&#039;] = $formattedresults;
header(&#039;Location: &#039; . $_SERVER[&#039;HTTP_REFERER&#039;]);
exit;
?&gt;
</pre>
<h4>Important Note</h4>
<p><strong>We are having a small issue with the code syntax formatting, be sure the '&amp;' signs in the url on line 9 above do *not* have a semicolon after them. Please see 'Renes' comment below for more.  Apologies for the inconvenience!</strong></p>
<h3>Step 3: The results page - back to search.php</h3>
<p>I know you're itching to see the results. So was I! Boy I wish I could do it all over again for the first time...</p>
<p>Anyway, the HTML formatted results are now stored in a PHP session variable from querygoogle.php. Groovy. All we have to do is display them and add some more CSS to make the results look sexy.</p>
<p>Make sure you can pull the results from the session by verifying that you are starting the session at the beginning of search.php and then echo the results. See below for the final search.php code (we started it in Step 1):</p>
<pre class="brush: php">
&amp;lt;?php
session_start();
?&amp;gt;

&lt;form method=&quot;post&quot; action=&quot;querygoogle.php&quot;&gt;
&lt;label for=&quot;searchquery&quot;&gt;&lt;span class=&quot;caption&quot;&gt;Search this site&lt;/span&gt; &lt;input type=&quot;text&quot; size=&quot;20&quot; maxlength=&quot;255&quot; title=&quot;Enter your keywords and click the search button&quot; name=&quot;searchquery&quot; /&gt;&lt;/label&gt; &lt;input type=&quot;submit&quot; value=&quot;Search&quot; /&gt;
&lt;/form&gt;

&amp;lt;?php
if(!empty($_SESSION[&#039;googleresults&#039;]))
{
echo $_SESSION[&#039;googleresults&#039;];
unset($_SESSION[&#039;googleresults&#039;]);
}
?&amp;gt;
</pre>
<p>Your search results work! But they're ugly. Here's some sexy CSS like I promised to get your started.</p>
<pre class="brush: css">
body
{
background-color: #000;
color: #ccc;
font: .75em/1.5em Arial, sans-serif; /* EMs calculated with pxtoem.com */
padding: 1.5em;
margin: 0;
width: 40em;
}

.searchresult
{
padding: 1.5em 0;
border-bottom: 1px solid #333;
}

.searchresult h3, .searchresult p
{
margin: 0;
}

.searchresult h3 a
{
font: italic 1em Georgia, serif;
color: #f30;
border-bottom: 1px solid #900;
text-decoration: none;
font-weight: bold;
font-size: 1em;
}

.searchresult .resultdesc b
{
color: #fff;
}

.searchresult .resulturl
{
color: #666;
font-size: .75em;
}
</pre>
<p>If you'd like to style your own results your way, each result will be placed in the following HTML format:</p>
<pre class="brush: html">
&lt;div class=&quot;searchresult&quot;&gt;
&lt;h3&gt;&lt;a href=&quot;page-url&quot;&gt;Page Title&lt;/a&gt;&lt;/h3&gt;
&lt;p class=&quot;resultdesc&quot;&gt;Page description/highlights&lt;/p&gt;
&lt;p class=&quot;resulturl&quot;&gt;URL that google always shows in green&lt;/p&gt;
&lt;/div&gt;
</pre>
<h3>Step 3+1: Celebrate!</h3>
<p>Congratulations! Your clients are happy. You've worked hard and you should take some "you time."</p>
<h3>Need Web Hosting?</h3>
<p>If you're looking for a <a href='http://webhostingsearch.com' title='Quality Web Hosting'>quality web host</a>, check out <a href="http://webhostingsearch.com" title="Quality">Web Hosting Search</a> for an array of quality hosting services.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/php-tip-add-custom-google-search-results-to-your-site-with-php/feed</wfw:commentRss>
		<slash:comments>76</slash:comments>
		</item>
		<item>
		<title>jQuery Tip : How to Select Radio/Checkbox Input On Click</title>
		<link>http://dev-tips.com/featured/jquery-tip-how-to-select-radiocheckbox-input-on-click</link>
		<comments>http://dev-tips.com/featured/jquery-tip-how-to-select-radiocheckbox-input-on-click#comments</comments>
		<pubDate>Sun, 11 Jan 2009 01:43:35 +0000</pubDate>
		<dc:creator>Barry Roodt</dc:creator>
				<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=80</guid>
		<description><![CDATA[I've been faced with the following scenario a few times during my web development career : First, you have an unordered list - within each list item you have a radio input. Secondly, when you click on the list item (i.e. the entire container), it must select the radio input and add a css classname [...]]]></description>
			<content:encoded><![CDATA[<p>
I've been faced with the following scenario a few times during my web development career : First, you have an unordered list - within each list item you have a radio input. Secondly, when you click on the list item (i.e. the entire container), it must select the radio input and add a css classname of "selected" to the list item, thus highlighting the item that has been selected.<br />
The following example will explain how to implement a workable solution. For a preview of what we will achieve, check out the <a href='http://dev-tips.com/demo/jquery_radio.html'>demo</a>.
</p>
<p><span id="more-80"></span></p>
<h3>The HTML :</h3>
<pre class="brush: html">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
&lt;head&gt;
	&lt;!-- include our jquery scripts --&gt;
    &lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;js/radio.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;style type=&quot;text/css&quot;&gt;
    	li { color: #000; }
    	li.selected { color: #FF0000; }
    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;div&gt;
		&lt;ul&gt;
			&lt;li class=&quot;test&quot;&gt;Test 1 &lt;input type=&quot;radio&quot; name=&quot;test&quot; /&gt;&lt;/li&gt;
			&lt;li class=&quot;test&quot;&gt;Test 2 &lt;input type=&quot;radio&quot; name=&quot;test&quot; /&gt;&lt;/li&gt;
			&lt;li class=&quot;test&quot;&gt;Test 3 &lt;input type=&quot;radio&quot; name=&quot;test&quot; /&gt;&lt;/li&gt;
			&lt;li class=&quot;test&quot;&gt;Test 4 &lt;input type=&quot;radio&quot; name=&quot;test&quot; /&gt;&lt;/li&gt;
			&lt;li class=&quot;test&quot;&gt;Test 5 &lt;input type=&quot;radio&quot; name=&quot;test&quot; /&gt;&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>There is nothing out of the ordinary here - just a simple unordered list of radio inputs.<br />
There's a basic stylesheet to highlight "selected" items.</p>
<p>For those of you wondering why I'm including the jQuery library from the Google Code repository :</p>
<ol>
<li>It saves on bandwidth, it'll load very quickly from Google's CDN.</li>
<li>It'll already be cached if the user has visited a site which also delivers it from Google Code.</li>
</ol>
<h3>Our Javascript/jQuery:</h3>
<pre class="brush: js">
$(document).ready(function(){
	$(&#039;li&#039;).click( function(){
		$(&#039;li.selected&#039;).removeClass(&#039;selected&#039;);
		$(this).addClass(&#039;selected&#039;).children(&quot;input[@type=radio]&quot;).click();
	});
});
</pre>
<p>As you can see, the actual code involved is short and straightforward - just the way we like it.</p>
<ol>
<li> First - we tell jQuery to execute the following code once the document has finished loading, ensuring that the DOM has been registered successfully.</li>
<li>Next we bind a click event to all list item elements on the page - you can of course change this to all list items with a class of "myselection" for example ( $("li.myselection").click... )</li>
<li>When a list item is clicked - we first need to remove the "selected" class from any previously "selected" list items.</li>
<li>Now we need to add the "selected" class to the list item which fired the event ( $(this) ).</li>
<li> Finally, we need to make sure that the radio button inside the list item is "clicked" : we do this by using the .children() selector and executing a click() event on the input. </li>
</ol>
<p>The important bit is the <strong>.children("input[@type=radio]")</strong> selector. Known as an <a href='http://dev-tips.com/featured/jquery-tip-using-xpath-selectors'>XPath selector</a>. What we're doing here is telling jQuery to find all all radio inputs inside "this" list item. We then use .click() to..as you guessed it... execute a click event on the returned element (in this case the radio input).</p>
<p>And that's all there is to it. You can read up some more on <a href="http://docs.jquery.com/Selectors" title="jQuery docs - selectors">jQuery selectors here</a>.<br />
I would also highly recommend reading the following article : <a href="http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx" title="Improve your jQuery">Improve your jQuery - 25 excellent tips</a>.</p>
<h3><a href='http://dev-tips.com/demo/jquery_radio.html'View the Demo</a></h3>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/jquery-tip-how-to-select-radiocheckbox-input-on-click/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>jQuery Tip: Quick and Easy Font Resizing</title>
		<link>http://dev-tips.com/featured/jquery-tip-quick-and-easy-font-resizing</link>
		<comments>http://dev-tips.com/featured/jquery-tip-quick-and-easy-font-resizing#comments</comments>
		<pubDate>Thu, 08 Jan 2009 03:02:42 +0000</pubDate>
		<dc:creator>Drew Douglass</dc:creator>
				<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=68</guid>
		<description><![CDATA[One of the many great features of jQuery is how easy it is to edit the css via a user event, such as a click. We can use this to knowledge to edit any css property we wish. Recently, NETTUTS had a great article that went all out with a font resizing slider bar using [...]]]></description>
			<content:encoded><![CDATA[<p>One of the many great features of jQuery is how easy it is to edit the css via a user event, such as a click. We can use this to knowledge to edit any css property we wish. Recently, NETTUTS had a great article that went all out with a <a href='http://nettuts.com/tutorials/javascript-ajax/use-the-jquery-ui-to-control-the-size-of-your-text/' title='Font resizing sliding bar'>font resizing slider bar</a> using the jQuery UI. While this article was certainly in-depth and well done, we want something quick and simple. Today we will create a simple script to allow the user to edit the current font size of an element.</p>
<p><span id="more-68"></span></p>
<h3>Our Goal</h3>
<p>Before starting any project, we need to know what we want to do. We want a simple and quick script to resize the text within a certain element 'on click'.</p>
<h3>Basic HTML</h3>
<p>First thing we need to do is setup our simple HTML page, we will use the code below for the demo.</p>
<pre class="brush: html">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;

&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
&lt;head&gt;
	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;
	&lt;meta name=&quot;author&quot; content=&quot;Drew Douglass&quot; /&gt;
	&lt;meta name=&quot;description&quot; content=&quot;&quot; /&gt;
	&lt;meta name=&quot;keywords&quot; content=&quot;&quot; /&gt;
	&lt;title&gt;jQuery Font Size Change | Dev-Tips&lt;/title&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js&quot;&gt;&lt;/script&gt;
	&lt;script type=&#039;text/javascript&#039;&gt;

	&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
	&lt;h2&gt;Text Resizing with jQuery Demo.&lt;/h2&gt;
	&lt;input type=&#039;button&#039; value=&#039;Larger&#039; id=&#039;large&#039; /&gt;
	&lt;input type=&#039;button&#039; value=&#039;Smaller&#039; id=&#039;small&#039; /&gt;
	&lt;p&gt;Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h3>Setup some variables</h3>
<p>Now it's time to setup some variables to use later on in our script, I'll explain more after the code below.</p>
<pre class="brush: javascript">
$(function(){
		$(&#039;input&#039;).click(function(){
			var ourText = $(&#039;p&#039;);
			var currFontSize = ourText.css(&#039;fontSize&#039;);
			var finalNum = parseFloat(currFontSize, 10);
			var stringEnding = currFontSize.slice(-2);
</pre>
<p>First we use some shorthand jQuery, which is the same as using document.ready(). Next we will setup some variable to use when the input buttons are clicked. The variable ourText will be our paragraph to re size. The variable currFontSize gets the current font size of the paragraph. The variable finalNum uses the parseFloat function to convert the string into a floating point number (with a base of 10). The variable stringEnding gets the pixels or em ending so we can add it back on later.</p>
<h3>Conditional Statements</h3>
<p>Next we need to decide what to do depending on the button the user is clicking on.</p>
<pre class="brush: javascript">
if(this.id == &#039;large&#039;) {
				finalNum *= 1.2;
			}
			else if (this.id == &#039;small&#039;){
				finalNum /=1.2;
			}
			ourText.css(&#039;fontSize&#039;, finalNum + stringEnding);
		});
	});
</pre>
<p>The above should be pretty self-explanatory. If they clicked on the large button, we multiply the current font size by 1.2, and if they click on the small button the font size is divided by 1.2.</p>
<h3>Full Script</h3>
<p>Our final script looks like this:</p>
<pre class="brush: javascript">
$(function(){
		$(&#039;input&#039;).click(function(){
			var ourText = $(&#039;p&#039;);
			var currFontSize = ourText.css(&#039;fontSize&#039;);
			var finalNum = parseFloat(currFontSize, 10);
			var stringEnding = currFontSize.slice(-2);
			if(this.id == &#039;large&#039;) {
				finalNum *= 1.2;
			}
			else if (this.id == &#039;small&#039;){
				finalNum /=1.2;
			}
			ourText.css(&#039;fontSize&#039;, finalNum + stringEnding);
		});
	});
</pre>
<p>And that's it, we now have a quick and simple font resizing script using jQuery. Don't forget to check out the <a href='http://dev-tips.com/demo/jquery_font_size_change.html' title='jQuery font resize demo'>demo</a> below if you want to see it in action.</p>
<h3><a href='http://dev-tips.com/demo/jquery_font_size_change.html' title='Font resizing demo'>View the Demo</a></h3>
<h3>Update with animation!</h3>
<p>Due to the popularity of this article, we have published another font resizing script, this time with animations on the resize. Be sure to check it out '<a href='http://dev-tips.com/featured/jquery-tip-font-resizing-with-animation-effects'>Font resizing with animation effects.</a>'.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/jquery-tip-quick-and-easy-font-resizing/feed</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
		<item>
		<title>jQuery Tip: Resources for Creating Your Own Plugins</title>
		<link>http://dev-tips.com/featured/jquery-tip-resources-for-creating-your-own-plugins</link>
		<comments>http://dev-tips.com/featured/jquery-tip-resources-for-creating-your-own-plugins#comments</comments>
		<pubDate>Tue, 06 Jan 2009 13:10:02 +0000</pubDate>
		<dc:creator>Drew Douglass</dc:creator>
				<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=51</guid>
		<description><![CDATA[With jQuery easily becoming the quickest growing Javascript library on the market right now, it's no wonder the demand for quality tutorials is so high. One of jQuerys great features is the ability for anyone to quickly and easily create a plugin. Today, we will have a look at some extremely helpful resources to get [...]]]></description>
			<content:encoded><![CDATA[<p>With jQuery easily becoming the quickest growing Javascript library on the market right now, it's no wonder the demand for quality tutorials is so high. One of jQuerys great features is the ability for anyone to quickly and easily create a plugin. Today, we will have a look at some extremely helpful resources to get you started with created your own jQuery plugins.<br />
<span id="more-51"></span></p>
<h2>The Definite Guide to Creating a Practical Plugin</h2>
<div class='roundupImg'><img src='http://dev-tips.com/post_img/jquery_plugin_resources/img1.jpg' alt='Screenshot 1' /></div>
<p>First up we have an excellent article by Dan Wellman over at <a href='http://nettuts.com' title='NETTUTS'>NETTUTS.</a> This article is extremely in depth and aimed towards those who are new to jQuery but have used it before.</p>
<h3><a href='http://nettuts.com/tutorials/javascript-ajax/the-definitive-guide-to-creating-a-practical-jquery-plugin/' title='Creating a practical plugin'>Visit Article</a></h3>
<h2>Developing a jQuery plugin via Snook.ca</h2>
<div class='roundupImg'><img src='http://dev-tips.com/post_img/jquery_plugin_resources/img2.jpg' alt='Screenshot 2' /></div>
<p>Anyone who knows me knows that I am stalking Jonathan Snook. OK, maybe not stalking but the guy is a web dev hero. In this article he takes us through the process of getting ready to create your plugin and putting the code into action.</p>
<h3><a href='http://snook.ca/archives/javascript/jquery_plugin/' title='Snook.ca Plugin'>Visit Article</a></h3>
<h2>Building Your First jQuery Plugin</h2>
<div class='roundupImg'><img src='http://dev-tips.com/post_img/jquery_plugin_resources/img3.jpg' alt='Screenshot 3' /></div>
<p>In this plugin tutorial you learn how to create a plugin which truncates text, or in other words, allows you have a a drop down 'read more' effect.</p>
<h3><a href='http://blog.jeremymartin.name/2008/02/building-your-first-jquery-plugin-that.html' title='Building your first jquery plugin'>Visit Article</a></h3>
<h2>A Plugin Development Pattern</h2>
<div class='roundupImg'><img src='http://dev-tips.com/post_img/jquery_plugin_resources/img4.jpg' alt='Screenshot 4' /></div>
<p><a href='http://learningjquery.com' title='Learning jQuery'>Learning jQuery</a> brings us an excellent article aimed more towards the development steps and patterns of developing a basic jQuery plugin.</p>
<h3><a href='http://www.learningjquery.com/2007/10/a-plugin-development-pattern' title=''>Visit Article</a></h3>
<h2>Learn How to Create a jQuery Plugin</h2>
<div class='roundupImg'><img src='http://dev-tips.com/post_img/jquery_plugin_resources/img5.jpg' alt='Screenshot 5' /></div>
<p>Again, NETTUTS delivers with a quality tutorial on every single step of creating your first jQuery plugin. Be sure to check out <a href='http://blog.themeforest.net/tutorials/jquery-for-absolute-beginners-day-15/' title='jQuery for absolute beginners'>jQuery for absolute beginners</a>, a 15 day series by Jeffrey Way on the ThemeForest blog for some excellent tuts.</p>
<h3><a href='http://nettuts.com/javascript-ajax/learn-how-to-create-a-jquery-plugin/' title='Visit article'>Visit Article</a></h3>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/jquery-tip-resources-for-creating-your-own-plugins/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
