<?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>Devin R. Olsen Web Developer &#187; JavaScript Tutorials</title>
	<atom:link href="http://www.devinrolsen.com/category/javascript-tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devinrolsen.com</link>
	<description>From Developer to Developer Information and Sharing</description>
	<lastBuildDate>Fri, 20 Aug 2010 05:08:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Build jQuery Lava Lamp Menu Tabs</title>
		<link>http://www.devinrolsen.com/build-jquery-lava-lamp-menu-tabs/</link>
		<comments>http://www.devinrolsen.com/build-jquery-lava-lamp-menu-tabs/#comments</comments>
		<pubDate>Fri, 25 Dec 2009 09:05:00 +0000</pubDate>
		<dc:creator>Devin R. Olsen</dc:creator>
				<category><![CDATA[CSS Tutorials]]></category>
		<category><![CDATA[JavaScript Tutorials]]></category>
		<category><![CDATA[css menu tabs]]></category>
		<category><![CDATA[javascript menu tabs]]></category>
		<category><![CDATA[jquery lava lamp]]></category>
		<category><![CDATA[jquery menu tabs]]></category>
		<category><![CDATA[lava lamp menu]]></category>
		<category><![CDATA[lava lamp menu tabs]]></category>
		<guid isPermaLink="false">http://www.devinrolsen.com/?p=567</guid>
		<description><![CDATA[Here I am going to show you how to build "Lava Lam"p menu tabs. We will be using CSS / jQuery and a single image to maintain a 100% stretchy rounded corners menu tab or lava bubble if you will. This version of the Lava Lamp menu tabs works in IE6+ and all other browsers! ]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="alignnone size-full wp-image-569" title="equation" src="http://www.devinrolsen.com/wp-content/uploads/2009/12/equation1.gif" alt="equation" width="372" height="89" /></p>
<h3><a href="http://www.devinrolsen.com/wp-content/themes/typebased/demos/jquery/lavalamp" title="Lava Lamp Tutorial Example Demo">Click Here to See This Tutorial&#8217;s Example Demo</a></h3>
<p><object width="440" height="345"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=8502892&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><param name="wmode" value="transparent" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=8502892&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" wmode="transparent" allowscriptaccess="always" width="440" height="345"></embed></object>
<p><a href="http://vimeo.com/8502892">How to Build jQuery Lava Lamp Menu Tabs</a> from <a href="http://vimeo.com/user2898580">Devin R. Olsen</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>This effect is called &#8220;animated rounded menu tabs&#8221;. It&#8217;s a neat little effect that will work in all browsers including IE6+. somethings to note is that this technique uses a single image for its four corners and is stretchy in both width and height!</p>
<p>We are also using the jQuery JS lib to ensure our JS works across all browsers but also to cut  down on the amount of JS we uses to make this great effect. Here is the link I use in the video tutorial to use the jQuery lib from Google&#8217;s online repository.</p>
<pre>http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js</pre>
<p>Here is the full source if you want to just get down to studying the code.</p>
<pre>&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;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Devin R. Olsen - Lava Lamp Menu Tabs&lt;/title&gt;
&lt;style type="text/css"&gt;
#nav {width:500px;  background:#333; margin:0px; padding:0px 0px 0px 20px; color:#fff; position:relative;}
#nav li {float:left; display:inline; list-style:none; line-height:35px; position:relative; z-index:3;}
#nav li a { padding:0px 10px 0px; cursor:pointer; font-size:12px; display:inline; color:#fff;}
#nav li.rounder { position:absolute; left:0px; top:0px; margin:0px; padding:0px; display:none; z-index:2;}
#nav li.rounder img {position:absolute;}
.cornersWrap {position:relative; height:25px; width:auto; margin-top:5px; background:#fff;}
#nav, #nav li, #nav li a, #nav li.rounder {height:35px;}
#tl,#tr,#bl,#br {position:absolute; width:8px; height:8px; overflow:hidden;}
#tr,#tl {top:0px;}
#br,#bl {bottom:0px;}
#tr,#br {right:0px;}
#tl,#bl {left:0px;}
#tr img,#br img {left:-8px;}
#bl img,#br img {top:-8px;}
&lt;/style&gt;
&lt;script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
$(document).ready(function(){
	$("#nav li a").mouseover(function(){
		$("#nav li a").each(function(count){
			$(this).css({color:"#fff"});
		});
		$(this).css({color:"#000"});
		var offL =  $(this).offset().left - $("#nav").offset().left;
		var offW = $(this).width() + parseInt($(this).css("paddingLeft")) * 2;
		$("li.rounder").stop().animate({left:offL+"px", width:offW+"px"},295,function(){
			//IE6 1px Fix
			var trOff = $("#tr").offset().left + parseInt($("#tr").css("width"));
			var wrapWOff = $(".rounder").offset().left + parseInt($(".rounder").css("width"));
			var brOff = $("#br").offset().top + parseInt($("#br").css("height"));
			var wrapHOff = $(".cornersWrap").offset().top + parseInt($(".cornersWrap").css("height"));
			if(wrapWOff &gt; trOff){
				$("#tr,#br").attr("class","rFix");
			}
			$(".rFix").css({right:"-1px"});
			if(wrapHOff &gt; brOff){
				$("#br,#bl").attr("class","bFix");
			}
			$(".bFix").css({bottom:"-1px"});
		});
	});
});
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;div&gt;
    	&lt;ul id="nav"&gt;
        	&lt;li&gt;&lt;a href="#"&gt;Short&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="#"&gt;Longer&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="#"&gt;Kinda Long&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="#"&gt;Kinda Longer&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="#"&gt;Really Longer&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="#"&gt;A Really Lot Longer&lt;/a&gt;&lt;/li&gt;
            &lt;li class="rounder"&gt;
            	&lt;div class="cornersWrap"&gt;
                    &lt;div id="tl"&gt;&lt;img src="http://www.devinrolsen.com/wp-content/themes/typebased/images/rounder.gif" /&gt;&lt;/div&gt;
                    &lt;div id="tr"&gt;&lt;img src="http://www.devinrolsen.com/wp-content/themes/typebased/images/rounder.gif" /&gt;&lt;/div&gt;
                    &lt;div id="bl"&gt;&lt;img src="http://www.devinrolsen.com/wp-content/themes/typebased/images/rounder.gif" /&gt;&lt;/div&gt;
                    &lt;div id="br"&gt;&lt;img src="http://www.devinrolsen.com/wp-content/themes/typebased/images/rounder.gif" /&gt;&lt;/div&gt;
                &lt;/div&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
    &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.devinrolsen.com/build-jquery-lava-lamp-menu-tabs/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How to build a jQuery lightbox!</title>
		<link>http://www.devinrolsen.com/how-to-build-a-jquery-lightbox/</link>
		<comments>http://www.devinrolsen.com/how-to-build-a-jquery-lightbox/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 05:56:59 +0000</pubDate>
		<dc:creator>Devin R. Olsen</dc:creator>
				<category><![CDATA[JavaScript Tutorials]]></category>
		<category><![CDATA[build lightbox]]></category>
		<category><![CDATA[how to build lightbox]]></category>
		<category><![CDATA[jquery lightbox]]></category>
		<category><![CDATA[lightbox]]></category>
		<category><![CDATA[make a lightbox]]></category>
		<guid isPermaLink="false">http://www.devinrolsen.com/?p=562</guid>
		<description><![CDATA[Today I want to talk about everything lightbox! I want to not only show you how to build a lightbox with css and jQuery but also expose the road blocks solutions any normal developer runs when building a lightbox. I will also show you how to build the lightbox so that it works in IE6, IE7 and IE8 as well as all other major browsers.]]></description>
			<content:encoded><![CDATA[<p>Today I want to talk about EVERYTHING lightbox. I want to show you how to build your own lightbox using jQuery and CSS. Not only build it but explain to you the road blocks and work arounds any normal developer would run into. We will go over each step on how to make the lightbox work in IE6, IE7 and IE8 as well as all other browsers.</p>
<p><object id="stVEpSQEJIR19eQF9UWFNYXlFS" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="flashvars" value="video=stVEpSQEJIR19eQF9UWFNYXlFS" /><param name="src" value="http://www.screentoaster.com/swf/STPlayer.swf" /><param name="allowfullscreen" value="true" /><param name="wmode" value="transparent" /><embed id="stVEpSQEJIR19eQF9UWFNYXlFS" type="application/x-shockwave-flash" width="425" height="344" src="http://www.screentoaster.com/swf/STPlayer.swf" wmode="transparent" flashvars="video=stVEpSQEJIR19eQF9UWFNYXlFS" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Here is the completed code if you just want to study the little guy.</p>
<pre>&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;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Everything You Need to Know About a Lightbox!&lt;/title&gt;
&lt;script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"&gt;&lt;/script&gt;
&lt;style type="text/css"&gt;
#lightBox {width:100%; margin:50px 0px; text-align:center; display:none;}
#lightWrap {width:400px; background:#000; border:2px #ccc solid; margin:auto; color:#fff; position:relative;  z-index:2;}
#shade {width:100%; height:100%; position:absolute; top:0px; left:0px; background:#000; -moz-opacity:0.5; -khtml-opacity:0.5; opacity:0.5; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=50); display:none; z-index:1;}
#closeBox { width:16px; height:16px; line-height:15px; background:#F36; position:absolute; top:5px; right:10px; cursor:pointer;}
&lt;/style&gt;
&lt;script&gt;
$(document).ready(function(){
	$("#action").click(function(){
		$("#lightBox").fadeIn("fast");
		if($("body").height() &gt; $("body").offset().height){
				var sH = $("body").height();
			}else{
				var sH = $("body").offset().height;
		}
		$("#shade").css({height:sH+'px',}).slideDown("fast");
		$("#closeBox").click(function(){
			$("#lightBox").fadeOut("fast");
			$("#shade").slideUp("fast");
		});
	});
});
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;button id="action"&gt;Click Me&lt;/button&gt;
&lt;div id="lightBox"&gt;
	&lt;div id="lightWrap"&gt;
    	&lt;div id="closeBox"&gt;X&lt;/div&gt;
    	&lt;h2&gt;HELLO This is my very own custom built lightbox!!&lt;/h2&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;div id="shade"&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>Thanks Everyone!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devinrolsen.com/how-to-build-a-jquery-lightbox/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Drag 2 Share with CSS and jQuery</title>
		<link>http://www.devinrolsen.com/drag-2-share-css-and-jquery-tutorial/</link>
		<comments>http://www.devinrolsen.com/drag-2-share-css-and-jquery-tutorial/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 04:43:47 +0000</pubDate>
		<dc:creator>Devin R. Olsen</dc:creator>
				<category><![CDATA[JavaScript Tutorials]]></category>
		<category><![CDATA[drag and share]]></category>
		<category><![CDATA[drag share tutorial]]></category>
		<category><![CDATA[drag to share]]></category>
		<category><![CDATA[jquery drag tutorial]]></category>
		<guid isPermaLink="false">http://www.devinrolsen.com/?p=556</guid>
		<description><![CDATA[Makes sharing fun again! Here I am going to show you how I built my "Drag 2 Share" blog feature. We will be using CSS and jQuery. This effect will work in IE6, IE7 and IE8, FireFox, Safari and Google Chrome. I also included a zip of the project that you can study and expand upon.]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;"><strong><a title="jQuery / CSS Drag 2 Share" href="http://www.devinrolsen.com/Drag2Share.zip">Download your copy HERE!</a></strong></p>
<p style="text-align: left;">Ok here we are going to learn how to build the &#8220;Drag 2 Share&#8221; feature you see on my blogs. This little guy is just what your visitors need to feel like they are having fun when sharing. In its own little way it finally makes sharing FUN!</p>
<p><object id="stVEpSQEJIR19fSFlUU19ZUVZd" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="flashvars" value="video=stVEpSQEJIR19fSFlUU19ZUVZd" /><param name="src" value="http://www.screentoaster.com/swf/STPlayer.swf" /><param name="allowfullscreen" value="true" /><param name="wmode" value="transparent" /><embed id="stVEpSQEJIR19fSFlUU19ZUVZd" type="application/x-shockwave-flash" width="425" height="344" src="http://www.screentoaster.com/swf/STPlayer.swf" wmode="transparent" flashvars="video=stVEpSQEJIR19fSFlUU19ZUVZd" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devinrolsen.com/drag-2-share-css-and-jquery-tutorial/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Learning The Basics of jQuery Faster Than Ever!</title>
		<link>http://www.devinrolsen.com/learning-jquery-faster-than-ever/</link>
		<comments>http://www.devinrolsen.com/learning-jquery-faster-than-ever/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 12:00:41 +0000</pubDate>
		<dc:creator>Devin R. Olsen</dc:creator>
				<category><![CDATA[JavaScript Tutorials]]></category>
		<category><![CDATA[JavaScript jQuery]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[learn jQuery fast]]></category>
		<category><![CDATA[learning jQuery]]></category>
		<category><![CDATA[quickly learning jQuery]]></category>
		<guid isPermaLink="false">http://www.devinrolsen.com/?p=460</guid>
		<description><![CDATA[When ever someone is talking about jQuery the frist thing that should come to your mind is JavaScript, or rather client side (for the most part). jQuery was made so that you could &#8220;Write less, do more&#8221; in JavaScript as jQuery&#8217;s slogan says. To really understand jQuery you must think about what it is you [...]]]></description>
			<content:encoded><![CDATA[<p>When ever someone is talking about jQuery the frist thing that should come to your mind is JavaScript, or rather client side (for the most part). jQuery was made so that you could &#8220;Write less, do more&#8221; in JavaScript as jQuery&#8217;s slogan says. To really understand jQuery you must think about what it is you need to know first:</p>
<ul style="margin-bottom:60px;">
<li>What is jQuery?</li>
<li>When do I use jQuery?</li>
<li>How do I use jQuery?</li>
</ul>
<h3>What is jQuery?</h3>
<p>jQuery was made by <a href="http://ejohn.org/">John Resig</a> and the <a href="http://docs.jquery.com/Contributors">jQuery Team</a>. jQuery is a JavaScript library that sums up popular JavaScript functionality and or methods into neat, very cross browser / version friendly little functions if you will.</p>
<p>jQuery now is broken up into two areas of library&#8217;s, we have the standard jQuery library that mainly sums up most JavaScript standard functionality. We also have the jQuery UI library for helping to build rich and interactive internet application user interfaces.</p>
<p>Both jQuery and jQuery UI, separate or together are considerably tiny in comparison to all you can accomplish with one or the other. In a nut shell jQuery can do all the standard things JavaScript alone can do and then some, but much quicker and with less code.</p>
<h3>When Should I use jQuery?</h3>
<p>JavaScript should be used as the icing on the cake for most web sites however when dealing with internet applications that use AJAX as its crux JavaScript can be vital. So its up to the developer to determine what areas of his or her site / application should use JavaScript and how it should be able to fall back and still function without JavaScript.</p>
<p>NOW STOP, just at the point where you start to realize what areas should be using JavaScript, replace standard JavaScript with jQuery. It&#8217;s as simple as that folks. jQuery is not this big next gen method or scary tactics but simply a newer way to write the same old stuff, just quicker.</p>
<p>So to answer the question of when to use jQuery, I would have to say any time you use JavaScript in your sites or applications. With that said it is very important to note that you should not ditch the old methods of DOM and Traversing elements with JavaScript because jQuery still has a few little areas to improve on and being able to mix the old and the new can create some really great stuff.</p>
<h3>How do I use jQuery?</h3>
<p>First things first, be sure to download a copy of either standard <a href="http://jquery.com/">jQuery or both jQuery and jQuery UI</a> and include them into the header of your document like so:<br />
[sourcecode language='html']<head></p>
<p><strong><script src="jquery/jquery-1.3.2.js"></script></strong><br />
<strong><script src="jquery/ui/jquery-ui-1.7.2.custom.js"></script></strong><br />
</head>[/sourcecode]<br />
Next is jQuery syntax so lets talk about the infamous <strong>$</strong> cash char. When ever your documents are accessing the jQuery lib(s) and you use the <strong>$</strong> followed by () parentheses you are stating you are performing a jQuery action and its lib(s) better listen up.</p>
<p>Most of the time with jQuery you will first point to elements to perform some sort of action or gathering. With jQuery there are many ways to do this that previously, were very long and cross browser tedious. Like the old methods of JavaScript, the most basic of ways to point or gather from elements is through class names and elements id but now with jQuery its much simpler and robust.</p>
<p><em>Here is an example of the old DOM method of class and id element pointing.</em><br />
[sourcecode language='javascript']var element = document.getElementById(&#8221;elementsId&#8221;);<br />
var elements = document.getElementsByClassName(&#8221;elementsClass&#8221;);[/sourcecode]<br />
<em>Now check out jQuerys version:</em><br />
[sourcecode language='javascript']var element = $(&#8221;#elementsId&#8221;);<br />
var elements = $(&#8221;.elementsClass&#8221;);[/sourcecode]<br />
Ok wow right off the bat you can see that&#8217;s a lot simpler right?Things to notice are the jQuery innate $ followed by parentheses that surround either an element id or class.</p>
<p><strong><em>Note that for classes we use the . and for ids we use the #.</em></strong></p>
<p>We most commonly only use the <strong>#</strong> pound and <strong>.</strong> period when writing CSS. Does this mean we can use CSS in some way to gather our elements? That&#8217;s right, the developers of jQuery have gone as far as to allow you to not only declare elements one via id and class name, but also use CSS selectors, Holy CRAP Batman!!</p>
<p>If you dont know what CSS selectors are, I suggest you <a href="http://www.w3.org/TR/CSS2/selector.html">read up on them</a>. To put it simply, it&#8217;s a way to point to groups or very specific patterns of children and or sibling elements with CSS alone.</p>
<p>Here is a little example of using CSS selectors in a jQuery element gathering.</p>
<pre>Matches all child elements specified by "child" of elements specified by "parent".
<strong>var all = $("#main &gt; *");</strong>
Finds all inputs that are next to a label.
<strong>var inputs = $("label + input");</strong>
Matches the first selected element.
<strong>var firstOf = $("tr:first");</strong></pre>
<p>Check that out, not only can you point to elements with standard DOM class and id methods much quicker but you can use CSS selectors such as element type selector (<strong>label</strong> or <strong>input</strong>), Child selectors (<strong>&gt;</strong>) and even pseudo selectors (<strong>:first</strong>). There are a great deal more of selector types that <a href="http://docs.jquery.com/Selectors">jQuery has to offer, click here if you would like to read more</a>.</p>
<p>Ok, this is boring just showing you how to make variables that point to elements&#8230; let&#8217;s do get more in depth.</p>
<p>jQuery was designed so a developer such as yourself, could write great and very fast scripts and do so in one long string of a function if you will. Lets make simple example of adding a click function to an element in one of our documents. For argument sakes, let&#8217;s say we have a <strong>&lt;button&gt;&lt;/button&gt;</strong> element that has an id of &#8220;<strong>#btn</strong>&#8220;. How would we add an onclick event to our element with jQuery?<br />
[sourcecode language='javascript']$(&#8221;#btn&#8221;).click();[/sourcecode]<br />
Again impressive how quickly you can write such things with jQuery. Believe it or not this has assigned a click event to our button element. Now lets add some function to the click event.<br />
[sourcecode language='javascript']$(&#8221;#btn&#8221;).click(function(){</p>
<p>});[/sourcecode]<br />
Ok I stated above that jQuery was designed for each function or jQuery declaration you make to be one long string. As you can see here we have found our element, assigned a click event and given anonymous function to the click event all with one string of code.</p>
<p>Because we have assigned anonymous function to our click event we can then use yet another jQuery selector the &#8220;<strong>this</strong>&#8221; selector. The &#8220;<strong>this</strong>&#8221; selector is nothing new to JavaScript, I however just wanted to point out its available also in jQuery.</p>
<p>So let&#8217;s do something fun to our button shall we.<br />
[sourcecode language='javascript']$(&#8221;#btn&#8221;).click(function(){<br />
    $(this).animate();<br />
    $(this).css();<br />
});[/sourcecode]<br />
Great see how because we are with in this buttons elements <strong>click</strong> event, its acceptable to use the <strong>$(this)</strong> selector. Also notice we have introduced two new jQuery calls, <strong>animate()</strong> and <strong>css()</strong>. The <strong>animate()</strong> is, well you guessed it animates certain aspects of an element such as height, width font size and borders. The <strong>css()</strong> is simply a way to directly set css style to elements without any animations or limitations.</p>
<p>Lets give our button an animated font size of 25px and a background color of black.<br />
[sourcecode language='javascript']$(&#8221;#btn&#8221;).click(function(){<br />
    $(this).animate({<br />
        fontSize: &#8220;25px&#8221;,<br />
        color: &#8220;#fff&#8221;<br />
    });</p>
<p>    $(this).css({<br />
        backgroundColor:&#8221;#000&#8243;<br />
    });<br />
});[/sourcecode]<br />
Here is an example of the above code:<br />
<button id="btn">Click Me Please!</button></p>
<p>Works great! Lets take a look at what we added shall we.</p>
<p>First with-in both animate() and css() parentheses we add a pair of curly brackets (<strong>{ }</strong>). We then list out both the style names such as, fontSize a colon : and finally the styles value within quotes. Again notice how we use the same setup for CSS style in both animate and css jQuery calls and how simple it all really is.</p>
<p>If you would like to see all the basic effects such as animate one can do with jQuery <a href="http://docs.jquery.com/Effects">simply go here</a>.</p>
<p>In the sakes of making this tutorial short, lets recap what we have learned. We learned what jQuery is and when best to use it. We also learned how to declair the use of jQuery and how to point to different elements with ids, classes and even CSS selectors. We learned how to assign an event to an element and give the event functionality. We even learned how to alter and even animate an elements CSS. I hope you can walk away with a bit of confidence in what jQuery is and how to get started using it. Its up to you to go and read up on all jQuery has to offer, or better yet see if jQuery already offers a quicker way to an old traditional JavaScript method.</p>
<p>jQuery has covered almost all areas of JavaScript and produced better, quicker and far more cross browser friendly ways to do them.</p>
<p>Here is a little list of links that will provide you some great insight into all the areas jQuery offers to assist you the next time you goto write your JavaScripts.</p>
<p><a href="http://docs.jquery.com/Selectors">All jQuery Selectors</a></p>
<p><a href="http://docs.jquery.com/Traversing">All jQuery Traversing Methods</a></p>
<p><a href="http://docs.jquery.com/Manipulation">All jQuery Manipulation Methods</a></p>
<p><a href="http://docs.jquery.com/CSS">All jQuery CSS Methods</a></p>
<p><a href="http://docs.jquery.com/Events">All jQuery Events</a></p>
<p><a href="http://docs.jquery.com/Effects">All jQuery Effects</a></p>
<p>Thats your jQuery crash course everyone.</p>
<p>Thanks!</p>
<p>Devin R. Olsen</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devinrolsen.com/learning-jquery-faster-than-ever/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Learning Intermediate JavaScript Faster Than Ever!</title>
		<link>http://www.devinrolsen.com/intermediate-javascript-tutorial/</link>
		<comments>http://www.devinrolsen.com/intermediate-javascript-tutorial/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 02:11:46 +0000</pubDate>
		<dc:creator>Devin R. Olsen</dc:creator>
				<category><![CDATA[JavaScript Tutorials]]></category>
		<category><![CDATA[Document]]></category>
		<category><![CDATA[Document Object Modeling]]></category>
		<category><![CDATA[DOM Scripting]]></category>
		<category><![CDATA[Intermediate JavaScript]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[JavaScript Lesson]]></category>
		<category><![CDATA[JavaScript Tutorial]]></category>
		<category><![CDATA[Modeling]]></category>
		<category><![CDATA[Object]]></category>
		<guid isPermaLink="false">http://www.devinrolsen.com/?p=440</guid>
		<description><![CDATA[&#8220;I feel I have painted my self into a corner with these tutorial titles for the simple fact that one persons advance is another persons child&#8217;s play. Who is to say whats intermediate and whats really advanced? No one is, and that&#8217;s my point.&#8221;
&#8220;In no way am I saying this is as intermediate or advanced [...]]]></description>
			<content:encoded><![CDATA[<p><em>&#8220;I feel I have painted my self into a corner with these tutorial titles for the simple fact that one persons advance is another persons child&#8217;s play. Who is to say whats intermediate and whats really advanced? No one is, and that&#8217;s my point.&#8221;</em></p>
<p><em>&#8220;In no way am I saying this is as intermediate or advanced as JavaScript gets! I would also like to point out that this may very well not be what you would consider to be intermediate or advanced JavaScript techniques. So with that said, I ask you to think before you post idiotic comments because, at one point you too were a beginner. This is what this series is about and who it&#8217;s for.&#8221;</em></p>
<p><em><strong>T</strong></em>oday we are going to take a step further down the path of  JavaScript greatness. Last time we learned a whole bunch about the basics of JavaScript. We learned what a variable is, how we can store information into them and how we can use that information. We also learned how to make a function and pass variables to a function in two different ways. We even learned about if else conditions.</p>
<p>Lets take it up a notch shall we? Instead of plundering into the massive amounts of native function JavaScript has to offer, let&#8217;s go a different direction. Let talk a little about Document Object Modeling or DOM Scripting for short.</p>
<p>So how do we begin to learn DOM you ask? Simple in order to learn it we must break it down in to very simple questions.</p>
<p><strong>- What is DOM Scripting?</strong></p>
<p><strong>- When Do I Use DOM Scripting?</strong></p>
<p><strong>- How Do I Use DOM Scripting?</strong></p>
<p>Lets begin shall we&#8230;<strong><br />
</strong></p>
<h2>What is DOM Scripting?</h2>
<p>DOM Scripting is an important asset to any JavaScript expert, but what is DOM Scripting and why are we learning DOM Scripting when we are here to learn freaking JavaScript? Ok first, DOM Scripting IS JavaScript you see, its simply a better way of gathering elements, attributes and values to do some really cool stuff. DOM is also W3C recommended for valid JavaScript across all major browsers.</p>
<h2>When Do I use DOM Scripting?</h2>
<p>If and when you are creating a script and it needs to gather, place or manipulate values or even elements them self&#8217;s you are going to be using DOM Scripting FACT.</p>
<p>DOM scripting has taken on its own form aside from JavaScript because it&#8217;s a collation of how to do things right across all browser the first time. Many people make the mistake of trying to learn everything about JavaScript first but are left wondering how to gather information out of elements. This is why I took our lesson today to this area proceeding our first tutorial. So again when do you use DOM Scripting? When ever you need to manipulate or receive something from an element.</p>
<h2>How Do I use DOM Scripting?</h2>
<p>The name says it all my friend.</p>
<p><strong>Document</strong> (refers to the document the script is being performed on.)</p>
<p><strong>Object</strong> (refers to the object or element our script is trying to get at.)</p>
<p><strong>Modeling</strong> (modeling is what we do with the object or get out of the object once we have retrieved it.)</p>
<p>Don&#8217;t feel over whelmed if the above did not make sense right now, simple think about it like this.</p>
<p>When ever you visit a web page, each page is a document correct?</p>
<p>Each document is made up of different elements that makes up the web site correct?</p>
<p>If we had some JavaScript to run on one of these pages, most of the JavaScript would be dealing with these elements or values from elements right?</p>
<p>So the whole goal here is to be able to identify a document, grab any of its elements, and model the element or information from the element however we want with our JavaScript.</p>
<p>How do we do such a thing you ask, well lets create an example document like so:</p>
<pre>&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;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;My First DOM Scripting Lesson&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="myFirstDOMElement" style="width:100px; height:105px; background:#000; color:#fff; text-align:center;"&gt;    THIS IS MY FIRST DOM ELEMENT!!&lt;/div&gt;
&lt;script type="text/javascript"&gt;
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>See our element between our body tags? It has an id of &#8220;<strong>myFirstDOMElement</strong>&#8221; so I am planing on trying to gather information out of this element by finding the element through its id alone. To do this, let&#8217;s go down to our script tags in our body and create a new variable like so:</p>
<pre>&lt;script type="text/javascript"&gt;
var element = document.getElementById();
&lt;/script&gt;</pre>
<p>Ok our new variable is named &#8220;<strong>element</strong>&#8221; and its equaling its self to first &#8220;<strong>document</strong>&#8221; to identify this document, then it&#8217;s using a native DOM function called &#8220;<strong>getElementById</strong>&#8220;. We fallow up the &#8220;<strong>getElementById</strong>&#8221; with a pair of parentheses and a semicolon to finish off the variable declaration. Next lets add the name of the element we wish to equal our variable too.</p>
<pre>&lt;script type="text/javascript"&gt;
var element = document.getElementById("myFirstDOMElement");
&lt;/script&gt;</pre>
<p>To give our DOM &#8220;<strong>getElementById</strong>&#8221; function a name of an element, we go into the parentheses and add quotation marks and finally the name of the element we wish to gather.</p>
<p>Guess what folks you just made your very first DOM call!</p>
<p>In reality we have only covered the document and object portion of DOM scripting if you will. The next part is the modeling of the element or its information. Lets do something with this element now that we have gathered it shall we.</p>
<p>Let first alert the id of the element out to use like so:</p>
<pre>&lt;script type="text/javascript"&gt;
var element = document.getElementById("myFirstDOMElement");
alert(element.id);
&lt;/script&gt;</pre>
<p><em>(fun things to try is to change .id to something like .style.background or .style.width or even .innerHTML)</em><br />
Here we are first using our &#8220;<strong>element</strong>&#8221; variable that we gathered with DOM and then, we alert its id attribute or rather the id value &#8220;<strong>.id</strong>&#8220;. <em>(In our last tutorial we covered the alert JavaScript feature.)</em></p>
<p>Holy crap it works!!</p>
<p>Ok to move forward with our lesson lets talk about the different ways a person can gather elements with DOM.</p>
<p>Our above example used &#8220;<strong>getElementById</strong>&#8221; but what if an id is not present or available for uses? We can use the &#8220;<strong>getElementsByTagName</strong>&#8221; to gather our element simple by the type of element it is.</p>
<p><em>(PLEASE note that this is &#8220;<strong>getElements</strong>&#8221; vs. our above &#8220;<strong>getElement</strong>&#8220;.)</em></p>
<p>This means with &#8220;<strong>getElementsByTagName</strong>&#8221; you are literally gathering every element on the page that is of the same type.</p>
<p>So how can one narrow down what element we want to get with &#8220;<strong>getElementsByTagName</strong>&#8220;? Well in the eyes of DOM each element is suppose to have a unique array number among each elements siblings elements. Soooo if we wanted to get our &#8220;example element&#8221; with the &#8220;<strong>getElementByTagName</strong>&#8221; we would do something like this:</p>
<pre>&lt;script type="text/javascript"&gt;
var element = document.getElementsByTagName("div")[0];
alert(element.id);
&lt;/script&gt;</pre>
<p>Notice how we first identify the document, then use the &#8220;<strong>getElementsByTagName</strong>&#8221; and use our examples element type. Now see how we have appended a pair of brackets containing a zero.</p>
<p>This appended number at the end our DOM call is this document array number I was talking about. Always note that 0 really means 1 or rather the first element, and it goes up from their.</p>
<p>Because our document only has one div element, we gather it with the &#8220;<strong>getElementByTagName</strong>&#8221; followed by its element array number 0.</p>
<p>Lets do something a little tricky with our example script now and learn a little about the parent and sibling DOM calls. Update your HTML to the following:</p>
<pre>&lt;div&gt;
&lt;div id="myFirstDOMElement" style="width:100px; height:105px; background:#000; color:#fff; text-align:center;"&gt;
THIS IS MY FIRST DOM ELEMENT!!
&lt;/div&gt;
&lt;div style="width:100px; height:105px; background:#000; color:#fff; text-align:center;"&gt;
THIS IS MY SECOND DOM ELEMENT!!
&lt;/div&gt;
&lt;/div&gt;</pre>
<p>Lets make a scenario that needs us to gather the contents of our second element. How would we go about gathering this or its information? The obvious way would be to first gather the first div or rather root element that contains our two other div elements like so:</p>
<pre>&lt;script type="text/javascript"&gt;
var parent = document.getElementsByTagName("div")[0];
&lt;/script&gt;</pre>
<p>Then our next step would be to use the &#8220;<strong>parent</strong>&#8221; variable with &#8220;<strong>getElementsByTagName</strong>&#8221; again to get the second elements contents like so:</p>
<pre>&lt;script type="text/javascript"&gt;var parent = document.getElementsByTagName("div")[0];
var element = parent.getElementsByTagName("div")[1];
alert(element.innerHTML);
&lt;/script&gt;</pre>
<p>But, this is to arbitrary if you ask me&#8230; lets do something  crazy and learn more shall we! Instead of gathering our first or rather root element if you will, lets point to our element with the id of &#8220;<strong>myFirstDOMElement</strong>&#8220;. Then let us introduce a new DOM feature called &#8220;<strong>nextSibling</strong>&#8221; like so:</p>
<pre>&lt;script type="text/javascript"&gt;
var first = document.getElementById("myFirstDOMElement");
var element = first.nextSibling;alert(element.innerHTML);
&lt;/script&gt;</pre>
<p>The &#8220;<strong>nextSibling</strong>&#8221; is just that, a way to move from one sibling element to another as long as the elements are truly siblings and not nested further from each other. There is also &#8220;<strong>previousSibing</strong>&#8221; and the same requirements or rather rules apply to this DOM call as well.</p>
<p>Ok so we now have a &#8220;<strong>nextSibling</strong>&#8221; and &#8220;<strong>previousSibling</strong>&#8221; but whats up with all these children DOM calls running around without any parents?</p>
<p>Lol well there actually is a &#8220;<strong>parentNode</strong>&#8221; DOM call and it simply jumps or traverses from a nested element, out to its parent element and only its parent element.</p>
<p>Great! Lets shake it up one more time and try to use all the DOM calls we have learned thus far. Here is what I have comp up with for fun:</p>
<pre>&lt;script type="text/javascript"&gt;
var first = document.getElementById("myFirstDOMElement");
var parent = first.parentNode;
var element = parent.getElementsByTagName("div")[1];
alert(element.innerHTML);
&lt;/script&gt;</pre>
<p>Awesome!</p>
<p>Ok so we know we can get elements by a tag names or even by an id or rather attribute and even how to traverse from sibling to parent elements, but what other attributes can a person gather elements with?</p>
<p>&#8220;<strong>getElementsByClassName</strong>&#8220;. Here we are pointing or rather gathering elements with a particular class name or attribute. Because it&#8217;s a class name we are after, and classes are non unique attributes like id&#8217;s we again are gathering all elements with a class name of our choice. All of this these DOM calls are methods to perform whats commonly called DOM Traversing.</p>
<p>Lets recap here what we have learned shall we?</p>
<p>Today we learned that DOM Scripting is a better way to gather elements or their values to perform JavaScript results out to us. We broke down Document Object Modeling and found it really means that we first identify the object, gather elements and use these elements or their values to model out results to us. We also learned how to use DOM to traverse to and from different elements based on their attributes or element type. We even learned that each element has a unique array number associated to it with in its sibling elements nested level.</p>
<p>There is much more to learn about DOM but I assure you, if you have completely understood this tutorial then you have a strong foundation to work with and gather elements for most scenarios faced with JavaScript.</p>
<p>And that&#8217;s your Intermediate JavaScript Lesson everyone!</p>
<p>Next we will be using all that we have learned from our first two lesson while digging deeper in to more native JavaScript features.</p>
<p>Thanks Everyone!</p>
<p>Devin R. Olsen</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devinrolsen.com/intermediate-javascript-tutorial/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Procedural Shadow Effect For Your Site Logo</title>
		<link>http://www.devinrolsen.com/procedural-shadow-effect/</link>
		<comments>http://www.devinrolsen.com/procedural-shadow-effect/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 07:16:27 +0000</pubDate>
		<dc:creator>Devin R. Olsen</dc:creator>
				<category><![CDATA[JavaScript Tutorials]]></category>
		<category><![CDATA[effect for logo]]></category>
		<category><![CDATA[logo shadow effect]]></category>
		<category><![CDATA[procedural shadow]]></category>
		<category><![CDATA[web logo shadow]]></category>
		<guid isPermaLink="false">http://devinrolsen.com/?p=314</guid>
		<description><![CDATA[So here we are, best of both worlds using JavaScript or rather W3C DOM Scripting and creating something very unique and elegant.]]></description>
			<content:encoded><![CDATA[<p>Do you notice anything dynamic about this logo? If not try moving your mouse around  it.</p>
<div id="wrap"><em>Click &amp; Drag Me</em></p>
<div id="element" style="margin: auto; background: #666666 none repeat scroll 0% 0%; overflow: hidden; width: 128px; height: 128px; position: relative;"><img id="object" style="margin: auto; position: absolute; top: 0px; left: 0px; z-index: 1;" src="http://devinrolsen.com/wp-content/themes/typebased/demos/javascript/procedural-shadow/images/object.png" alt="png object" /><br />
<img id="alpha" style="position: absolute; top: -6px; right: -6px; z-index: 0;" src="http://devinrolsen.com/wp-content/themes/typebased/demos/javascript/procedural-shadow/images/alpha.png" alt="png alpha" width="140px" height="140px" /></div>
</div>
<div style="height:180px;"></div>
<p>Still nothing? <strong>TURN JAVASCRIPT ON</strong>!</p>
<p>If you do in fact see this dynamic shadow effect working around this simple logo then this is what we are going to be talking about today! So get your JavaScript hats on cause here we go.</p>
<p>Ok  just so I don&#8217;t get flamed here, anybody of course you could use flash to pull something like this off but by using flash you are <strong>more limited</strong>&#8230; anyone mad yet? Let me explain, in the above example you can effect the shadow anywhere on the page with ease. You can also can place and drag the logo container anywhere on the page and still receive perfect shadow reaction.</p>
<p>If created in flash then our shadow effect could only be preformed once a user has move their mouse into the actual flash player. You could create a full page flash version of this but then you have to create the rest of your site in flash and that&#8217;s a HUGE NO NO for SEO!</p>
<p>So here we are, best of both worlds using JavaScript or rather W3C DOM Scripting and creating something very unique and elegant.</p>
<h3>HTML &#8211; CSS Portion</h3>
<p>Lets talk about the structure of this little guy:</p>
<pre>&lt;div id="wrap"&gt;
	&lt;em&gt;Click &amp; Drag Me&lt;/em&gt;
  &lt;div id="element"&gt;
  &lt;/div&gt;
&lt;/div&gt;</pre>
<p>Here are the basics, we have a div block with an id of wrap and its our main container for the logo and shadow pieces. Within this first div block is a second div block that has an id of element. This second block acts as our two logo images container but also is what makes up our shadow.</p>
<p>In this example we have two images both of the file type PNG24 and have alpha transparency. Our first image is our actual logo, in our example its the letter &#8220;D&#8221; this image is completely transparent except for the actual shape of the letter &#8220;D&#8221;. The second image is also using alpha transparency but into an inverted version compared to our first image. So we have two images one that uses alpha transparency to form our logo or rather red letter &#8220;D&#8221; and the other is a white image that too uses alpha transparency to cut out a shape of the letter &#8220;D&#8221;.</p>
<pre><a href="http://devinrolsen.com/wp-content/uploads/2009/09/object.png"><img class="alignnone size-full wp-image-331" style="float:left;" title="object" src="http://devinrolsen.com/wp-content/uploads/2009/09/object.png" alt="object" width="128" height="128" /></a>
<a href="http://devinrolsen.com/wp-content/uploads/2009/09/alpha.png"><img class="alignnone size-full wp-image-332" style="float:left;" title="alpha" src="http://devinrolsen.com/wp-content/uploads/2009/09/alpha.png" alt="alpha" width="140" height="140" /></a></pre>
<p><strong>Notice</strong> that the first image is smaller than the second. This is important to keep in mind but and we will get back to why this is so important here in a bit.</p>
<p>Take a look at this diagram of how the images are layered and carry their alpha transparency to one another.</p>
<p><a href="../wp-content/uploads/2009/09/fig12.jpg"><img title="fig1" src="../wp-content/uploads/2009/09/fig12.jpg" alt="fig1" width="447" height="284" /></a></p>
<p>Ok so now that we have and idea of how these two images transparency&#8217;s work work off one another lets look at how we place them into our html.</p>
<p>Make your html now look like this:</p>
<pre>&lt;div id="wrap"&gt;
	&lt;em&gt;Click &amp; Drag Me&lt;/em&gt;
    &lt;div id="element"&gt;
    <strong>&lt;img src="http://devinrolsen.com/wp-content/themes/typebased/demos/javascript/procedural-shadow/images/object.png" id="object" /&gt;
    &lt;img id="alpha" src="http://devinrolsen.com/wp-content/themes/typebased/demos/javascript/procedural-shadow/images/alpha.png" style="top:-6px; right:-6px; left:; bottom:;"/&gt;</strong>
  &lt;/div&gt;
&lt;/div&gt;</pre>
<p>Ok so just like in the above figure we have our two images stacked on top of each other. Our first image is named &#8220;<strong>object.png</strong>&#8221; and our second &#8220;<strong>alpha.png</strong>&#8221; one makes an object (our red letter &#8220;D&#8221;) and the other creates and alpha mask of the other.</p>
<p>The second image (<strong>alpha.png</strong>) carry&#8217;s some very important inline styles that must remain inline in order for our JavaScript to perform our shadow effect properly. Both top and right are set to -6px; and our left, bottom are set to null or nothing. We set both the top and right to -6px to offset our <strong>alpha.png</strong> and align it to our <strong>object.png</strong> image due to <strong>alpha.png</strong> being 12px larger than object.png. The reason there is no setting for the left and bottom styles is because these will be filled in dynamically by our javascript so its best to leave them empty for now.</p>
<p>Lets look at the rest of our CSS that finishes off our dynamic logos structure. Add the following to your documents header tags.</p>
<pre>&lt;style type="text/css"&gt;
    #wrap {
    height: 150px; width:150px;
    }
    #element{
    width:128px; height:128px; background:#666; position:relative; overflow:hidden;
    }
    #object{
    position:absolute; margin:auto; top:0px; left:0px; z-index:1;
    }
    #alpha{
    position:absolute; z-index:0;
    }
&lt;/style&gt;</pre>
<p>Ok lets run over why these styles are important to our desired results. First we have our div block element &#8220;wrap&#8221; and its style rule that gives it both a&#8221; width&#8221; and &#8220;height&#8221; of 150px. You can change this to what ever you desire.</p>
<p>Our next rule is for our &#8220;element&#8221; div block and it too states a width and height but only of 128px and we use 128px because our object.png image is 128px by 128px. We also set a position of relative to give us the ability to use children elements that have a position of absolute with out breaking them out of our structured flow. Our last two important styles are the background-color and overflow styles, we set our background color to be that of a darker one such as a shadow or shade. We set our overflow style to be hidden so that our alpha.png image that is larger than 128px will be hidden but also not bring about scroll bars.</p>
<p>Ok our next CSS rule is called &#8220;#object&#8221; and its for our element &#8220;object&#8221; or <strong>object.png</strong> and we set its position to be absolute so our JavaScript can perform our shadow effect. We have a both a top and left of 0px because with the position of absolute we want to make sure our &#8220;object&#8221; element is always in the upper left hand corner at all times. Our last rule is working in conjunction with our position of absolute and states our browser rendering hierarchy over any other elements that have a z-index style lower than 1.</p>
<p>Of course our last style rule is for our element &#8220;alpha&#8221; or <strong>alpha.png</strong> and it too is set to position of absolute and a z-index of 0. Again the z-index is set to a lower number than that of our #object rule in order to stack our object.png image over our alpha.png image respectively.</p>
<h3>JavaScript Portion</h3>
<p>There are two actions at distance in play here. Our mouse is feeding a JavaScript function its coordinates (X,Y) of its position on the page while this function makes sure our two images react accordingly.</p>
<p>In order for our mouse to event receive its coordinates a document must have a point of orgin for these coordinates.<br />
The point of orgin is the location of where both our X and Y intersect resulting in both X and Y to be zero. So we make our logo be the point of orgin for our mouse&#8217;s coordinates that feed to our JavaScript function.</p>
<p>Why we make our logo the point of orgin is so that placement of the logo on the page results in perfect reaction from both object and mouse.</p>
<p>Here is the JavaScript that handles our point of orgin.</p>
<pre style="overflow:scroll;">var divObj;
document.onmousemove=getMouseCoordinates;
function zxcMse(zxcevt){
 if(!zxcevt) var zxcevt=window.event;
 if (document.all) return [zxcevt.clientX+zxcDocS()[0],zxcevt.clientY+zxcDocS()[1]];
 return [zxcevt.pageX,zxcevt.pageY];
}
function zxcDocS(){
 if (!document.body.scrollTop) return [document.documentElement.scrollLeft,document.documentElement.scrollTop];
 return [document.body.scrollLeft,document.body.scrollTop];
}
function zxcPos(zxcobj){
 zxclft=zxcobj.offsetLeft;
 zxctop=zxcobj.offsetTop;
 while(zxcobj.offsetParent!=null){
  zxcpar=zxcobj.offsetParent;
  zxclft+=zxcpar.offsetLeft;
  zxctop+=zxcpar.offsetTop;
  zxcobj=zxcpar;
 }
 return [zxclft,zxctop];
}</pre>
<p>I wont go too much into this but basicly it creates an event handler that is gathering our mouse coordinates and point of orgin and relocating them to be that of an element.<br />
For us to use this event handler though we must also  setup a function that shifts our alpha image accordingly. Here is this function:</p>
<pre>function getMouseCoordinates(event)
{
	var ev = event || window.event;
	var element = document.getElementById("element");
	var alpha = document.getElementById("alpha");
	var mse=zxcMse(ev);
	var pos=zxcPos(element)
  	var cx=pos[0]+element.offsetWidth/2;
  	var cy=pos[1]+element.offsetHeight/2;
  	var x=(mse[0]-cx);
  	var y=(mse[1]-cy);
}</pre>
<p>This function has three parts to it that we must pay close attion to.</p>
<ul>
<li>The first part is that the function is named &#8220;<strong>getMouseCoordinate</strong>&#8221; and is calling to our event handler &#8220;event&#8221;.</li>
<li>The next part is the element we are pointing too named &#8220;element&#8221;.</li>
<li>The last part is the second element we are pointing too named &#8220;alpha&#8221;.</li>
</ul>
<p>Basicly what this is doing is takeing our &#8220;element&#8221; and &#8220;alpha&#8221; elements and setting the point of orgin for our mouse coordinates to them. In theroy now what ever coordinates we recive from our mouse will always be centered around these two objects.</p>
<p>The next thing we must create is our conditions for shifting the alpha image around based off these coordinates.</p>
<p>I never said this was going to be easy&#8230;</p>
<p>Lets start talking about what this JavaScript condition that shifts our alpha image is actuly doing. In a nut shell its stateing the following based on the mouse coordinates its recives.</p>
<pre>if(x coordinate is greater than 50)
{
	Shift alpha image to the left by so many pixels.
}
else if (x is greater than 75)
{
	Shift alpha image left again and by so many pixels.
}</pre>
<p>This conditional statement is also true for our negative numbers as our point of origin falls into both negative and positive numbers along both X and Y. Here is the above examples alpha image conditions for shifting both left right and top bottom.</p>
<pre>	///////////////
	//RIGHT SHIFT//
  ///////////////
	if(x&lt;-100){
		alpha.style.left="";
		alpha.style.right="-11px";
	}
	else if(x&lt;-80){
		alpha.style.left="";
		alpha.style.right="-10px";
	}
	else if(x&lt;-60){
		alpha.style.left="";
		alpha.style.right="-9px";
	}
	else if(x&lt;-40){
		alpha.style.left="";
		alpha.style.right="-8px";
	}
	else if(x&lt;-20){
		alpha.style.left="";
		alpha.style.right="-7px";
	}
	//////////////
	//LEFT SHIFT//
	//////////////
 	if(x&gt;100){
		alpha.style.right="";
		alpha.style.left="-11px";
	}
 	else if(x&gt;80){
		alpha.style.right="";
		alpha.style.left="-10px";
	}
 	else if(x&gt;60){
		alpha.style.right="";
		alpha.style.left="-9px";
	}
 	else if(x&gt;40){
		alpha.style.right="";
		alpha.style.left="-8px";
	}
 	else if(x&gt;20){
		alpha.style.right="";
		alpha.style.left="-7px";
	}
	////////////////
	//BOTTOM SHIFT//
	////////////////
	if(y&lt;-100){
		alpha.style.top="";
		alpha.style.bottom="-11px";
	}
	else if(y&lt;-80){
		alpha.style.top="";
		alpha.style.bottom="-10px";
	}
	else if(y&lt;-60){
		alpha.style.top="";
		alpha.style.bottom="-9px";
	}
	else if(y&lt;-40){
		alpha.style.top="";
		alpha.style.bottom="-8px";
	}
	else if(y&lt;-20){
		alpha.style.top="";
		alpha.style.bottom="-7px";
	}
	/////////////
	//TOP SHIFT//
	/////////////
	if(y&gt;100){
		alpha.style.bottom="";
		alpha.style.top="-11px";
	}
	else if(y&gt;80){
			alpha.style.bottom="";
			alpha.style.top="-10px";
	}
	else if(y&gt;60){
			alpha.style.bottom="";
			alpha.style.top="-9px";
	}
	else if(y&gt;40){
			alpha.style.bottom="";
			alpha.style.top="-8px";
	}
	else if(y&gt;20){
			alpha.style.bottom="";
			alpha.style.top="-7px";
	}</pre>
<p>Two thing to note here befor you are off to trying to edit this huge conditional statment. First each shifting direction steeps 5 times and based on 5 diffrent numbers given to it by our mouses coordinates. Each number shifts our alpha image either a little less or more in the its designated  direction.</p>
<p>Remeber how we talked about the html structure of this above and I told you that our alpha image has to be larger that our actule displaying area. This is true now because we must  use this extra image size to allow a proper shifting and seamless bleed off the containers edges.</p>
<p>Here is our script compleated:</p>
<pre>var divObj;
document.onmousemove=getMouseCoordinates;
function zxcMse(zxcevt){
 if(!zxcevt) var zxcevt=window.event;
 if (document.all) return [zxcevt.clientX+zxcDocS()[0],zxcevt.clientY+zxcDocS()[1]];
 return [zxcevt.pageX,zxcevt.pageY];
}
function zxcDocS(){
 if (!document.body.scrollTop) return [document.documentElement.scrollLeft,document.documentElement.scrollTop];
 return [document.body.scrollLeft,document.body.scrollTop];
}
function zxcPos(zxcobj){
 zxclft=zxcobj.offsetLeft;
 zxctop=zxcobj.offsetTop;
 while(zxcobj.offsetParent!=null){
  zxcpar=zxcobj.offsetParent;
  zxclft+=zxcpar.offsetLeft;
  zxctop+=zxcpar.offsetTop;
  zxcobj=zxcpar;
 }
 return [zxclft,zxctop];
}
function getMouseCoordinates(event)
{
	var ev = event || window.event;
	var element = document.getElementById("element");
	var alpha = document.getElementById("alpha");
	var mse=zxcMse(ev);
	var pos=zxcPos(element)
  	var cx=pos[0]+element.offsetWidth/2;
  	var cy=pos[1]+element.offsetHeight/2;
  	var x=(mse[0]-cx);
  	var y=(mse[1]-cy);
///////////////
//RIGHT SHIFT//
///////////////
if(x&lt;-100){alpha.style.left="";	alpha.style.right="-11px";}
else if(x&lt;-80){alpha.style.left="";	alpha.style.right="-10px";}
else if(x&lt;-60){alpha.style.left="";	alpha.style.right="-9px";}
else if(x&lt;-40){alpha.style.left="";	alpha.style.right="-8px";}
else if(x&lt;-20){alpha.style.left="";	alpha.style.right="-7px";}
//////////////
//LEFT SHIFT//
//////////////
if(x&gt;100){alpha.style.right=""; alpha.style.left="-11px";}
else if(x&gt;80){alpha.style.right=""; alpha.style.left="-10px";}
else if(x&gt;60){alpha.style.right=""; alpha.style.left="-9px";}
else if(x&gt;40){alpha.style.right=""; alpha.style.left="-8px";}
else if(x&gt;20){alpha.style.right=""; alpha.style.left="-7px";}
////////////////
//BOTTOM SHIFT//
////////////////
if(y&lt;-100){ alpha.style.top="";	alpha.style.bottom="-11px";}
else if(y&lt;-80){alpha.style.top=""; alpha.style.bottom="-10px";}
else if(y&lt;-60){alpha.style.top=""; alpha.style.bottom="-9px";}
else if(y&lt;-40){alpha.style.top=""; alpha.style.bottom="-8px";}
else if(y&lt;-20){alpha.style.top=""; alpha.style.bottom="-7px";}
/////////////
//TOP SHIFT//
/////////////
if(y&gt;100){alpha.style.bottom=""; alpha.style.top="-11px";}
else if(y&gt;80){alpha.style.bottom=""; alpha.style.top="-10px";}
else if(y&gt;60){alpha.style.bottom=""; alpha.style.top="-9px";}
else if(y&gt;40){alpha.style.bottom=""; alpha.style.top="-8px";}
else if(y&gt;20){alpha.style.bottom="";alpha.style.top="-7px";}
}</pre>
<p>Ok last thing I want to talk about is that in the above conditional statment I did not include the portions that create the highlight&#8217;s in the above demo. If you would like to see how this was created then download copy of this compleat script and demo in action and have fun!</p>
<p><strong><a title="complete dynamic javascript shadow effect script" href="http://devinrolsen.com/wp-content/themes/typebased/demos/javascript/procedural-shadow/scripts/dynamic-js-shadows.zip">DOWNLOAD A COMPLETE COPY OF THE SCRIPT</a></strong></p>
<p>Thanks.</p>
<p>Devin R. Olsen</p>
<p><script src="http://devinrolsen.com/wp-content/themes/typebased/demos/javascript/procedural-shadow/scripts/dynamicShadow.js" type="text/javascript"></script> <script src="http://devinrolsen.com/wp-content/themes/typebased/demos/javascript/procedural-shadow/scripts/wz_dragdrop.js" type="text/javascript"></script><br />
<script type="text/javascript">// <![CDATA[
SET_DHTML("wrap", "divBox2", "image1", "image2");
// ]]&gt;</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devinrolsen.com/procedural-shadow-effect/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>PNG 24 Alpha Transparency Fix For IE</title>
		<link>http://www.devinrolsen.com/png-24-aplah-fix/</link>
		<comments>http://www.devinrolsen.com/png-24-aplah-fix/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 06:55:37 +0000</pubDate>
		<dc:creator>Devin R. Olsen</dc:creator>
				<category><![CDATA[JavaScript Tutorials]]></category>
		<category><![CDATA[24]]></category>
		<category><![CDATA[png]]></category>
		<category><![CDATA[png 24]]></category>
		<category><![CDATA[png 24 fix]]></category>
		<category><![CDATA[png alpha fix]]></category>
		<category><![CDATA[png fix]]></category>
		<guid isPermaLink="false">http://devinrolsen.com/?p=301</guid>
		<description><![CDATA[I have been developing web sites and internet applications for many years now and there are many things that have bug me about design approaches but the one that always and still sticks out is the lack of PNG 24 alpha transparency in IE’s rendering engine.]]></description>
			<content:encoded><![CDATA[<p>I have been developing web sites and internet applications for many years now and there are many things that have bug me about design approaches but the one that always and still sticks out is the lack of PNG 24 alpha transparency in IE’s rendering engine.</p>
<p>PNG 24 image files support a very well executed alpha transparency that is far superior to that of transparent gif files. One example of this is the alpha transparent gradient that is not supported by transparent gif’s. PNG will gracefully fall off into complete alpha transparency perfectly when performing drop shadows or glow effects around or in images where as gif images that are transparent are either 0 or 1, colored or transparent.</p>
<p>Here is an example of the two.</p>
<p><label><strong>GIF Transparency</strong></label></p>
<p>(<strong>Note</strong>: Arrow is pointing to the 0 and 1 binary transparency gif images only supports)</p>
<p><a href="http://devinrolsen.com/wp-content/uploads/2009/09/gif_transparency.jpg"><img class="alignnone size-full wp-image-297" title="gif_transparency" src="http://devinrolsen.com/wp-content/uploads/2009/09/gif_transparency.jpg" alt="gif_transparency" /></a></p>
<p><label><br />
<strong>PNG 24 Transparency</strong><br />
</label></p>
<p><a href="http://devinrolsen.com/wp-content/uploads/2009/09/png_transparency.jpg"><img class="alignnone size-full wp-image-300" title="png_transparency" src="http://devinrolsen.com/wp-content/uploads/2009/09/png_transparency.jpg" alt="png_transparency" /></a></p>
<p>Another thing that is wrong or rather troublesome with gif images is the fact that if you do carry transparency in a gif image, the defining point of where transparency and non-transparency begins becomes jagged with pixels. The only fix for this is to have a matte color that surrounds the gif images defining transparent points that matches the background color of which the image is being laid over. This is not only hokey but sometimes a dead end to your design if you want to have gradient backgrounds that the gif image is going to be laid over.</p>
<p>Here is an example of the gif transparency jagged problem.</p>
<p><label><strong>GIF Transparency</strong></label></p>
<p>(<strong>Note</strong>: See the jagged edges in the GIF image and the matte border</p>
<p>around the image that&#8217;s trying to and clear up the jagged edges with<br />
a background color match.)</p>
<p><a href="http://devinrolsen.com/wp-content/uploads/2009/09/gif_jagged.jpg"><img class="alignnone size-full wp-image-296" title="gif_jagged" src="http://devinrolsen.com/wp-content/uploads/2009/09/gif_jagged.jpg" alt="gif_jagged" /></a></p>
<p><label><strong>PNG 24 Transparency</strong></label></p>
<p>(<strong>Note</strong>: No jagged edges and no need for matte color matching)</p>
<p><a href="http://devinrolsen.com/wp-content/uploads/2009/09/png_no_jagged.jpg"><img class="alignnone size-full wp-image-299" title="png_no_jagged" src="http://devinrolsen.com/wp-content/uploads/2009/09/png_no_jagged.jpg" alt="png_no_jagged" /></a></p>
<p>Now that we can see why PNG 24 images are better to use when performing transparency vs  gif images, let’s look at the problem we have when trying to use PNG 24 images on IE browsers.</p>
<p>IE rendering engine is not of the best compared to a lot of well used browsers such as Fire fox and Safari and in fact is ridiculed as being the worst browser to develop sites on because of all the hacking and patching users have to do in order to make their designs perform correctly in IE browsers. So it’s no surprise that this is the same  when trying to use PNG 24 images and the IE browser.</p>
<p>When IE 7 came out there was a sigh of relief when it was announced that IE7 will finally support PNG 24 images and the alpha transparency we would like to have. Unfortunately this was a blatant lie on IE’s part because we were in fact still left with no PNG 24 support as the previously claimed.</p>
<p>Let’s take a look at what the effect of the PNG 24 looks like when trying to run them on IE.</p>
<p><label><strong>PNG Transparency in IE</strong></label></p>
<p>(<strong>Note</strong>: Any alpha areas are replaced with a mint green color or sometimes gray.)</p>
<p><a href="http://devinrolsen.com/wp-content/uploads/2009/09/IE_png.jpg"><img class="alignnone size-full wp-image-298" title="IE_png" src="http://devinrolsen.com/wp-content/uploads/2009/09/IE_png.jpg" alt="IE_png" /></a></p>
<p><label><strong>PNG Transparency in all other browsers</strong></label></p>
<p>(<strong>Note</strong>: All alpha transparency areas are working perfectly)</p>
<p><a href="http://devinrolsen.com/wp-content/uploads/2009/09/FF_png.jpg"><img class="alignnone size-full wp-image-295" title="FF_png" src="http://devinrolsen.com/wp-content/uploads/2009/09/FF_png.jpg" alt="FF_png" /></a></p>
<p>Wow that is just plain ugly!! So how do we fix this issue you might be asking yourself? Well there are lots of fixes out on the net that range from CSS filters to giving up on PNG 24 images and using PNG 8 images. All of these solutions are either breakers for other browser or ugly results of PNG 8 images. This year (2008) however a great little nifty JavaScript code hit the scene that has opened a world of possibilities to web designers and PNG 24 alpha transparency images and is being hailed as the end all solution to fix  PNG 24 alpha transparency support in IE browsers.</p>
<p>This light weight and easy to implement JavaScript patch for PNG 24 alpha transparency and IE browser is called</p>
<p>&#8220;<strong>Unit PNG Fix</strong>&#8221; and was developed by <a href="http://labs.unitinteractive.com">Unit Interactive:Labs</a>. I of course at first glance was a skeptic as I have been down many roads of the so called PNG Fix and never found one the truly is a fix or easily integrated. This &#8220;Unit PNG Fix&#8221; however was the one that I as well as many other developers had been long awaiting for  and quickly fell in love with. I like it so much I am using it right here on the web site you are reading this tutorial from.</p>
<p>Let’s take a look at how this PNG 24 alpha transparency fix for IE is implemented into our designs.</p>
<p>Download the PNG 24 fix from here <a href="http://labs.unitinteractive.com/unitpngfix.php">http://labs.unitinteractive.com/unitpngfix.php</a> and un-zip it’s contents.</p>
<ul>
<li>Unitpngfix.js</li>
<li>Clear.gif</li>
</ul>
<p>There may be other contents in the zip file such as readme.txt files, but for now all we need are these two files.</p>
<p>In your html documents header simply add this IE 7 or later comment argument that calls our unit PNG fix for IE 7 and below.</p>
<pre>&lt;!--[if lt IE 7]&gt;
        &lt;script type="text/javascript" src="unitpngfix.js"&gt;&lt;/script&gt;
&lt;![endif]--&gt;</pre>
<p>(<strong>Note:</strong> Make sure you point this to the proper location you would like to have the JavaScript file reside on your web server.)</p>
<p>Next open up the unitpngfix.js and on the very first line you will see a path to where your clear.gif file is. Make sure you make this path point correctly to where you would like to have this clear.gif reside on your web server as well.</p>
<p>Hit save to the unitpngfix.js and your html document and that’s it!!</p>
<p>Now you can support PNG 24 alpha transparency across all browsers.</p>
<p>Hope you enjoyed this little article as much as I have.</p>
<p><strong>Devin R. Olsen</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devinrolsen.com/png-24-aplah-fix/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Simple JavaScript Form Validation</title>
		<link>http://www.devinrolsen.com/simple-javascript-form-validation/</link>
		<comments>http://www.devinrolsen.com/simple-javascript-form-validation/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 08:47:35 +0000</pubDate>
		<dc:creator>Devin R. Olsen</dc:creator>
				<category><![CDATA[JavaScript Tutorials]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[javascript validation]]></category>
		<category><![CDATA[simple form]]></category>
		<category><![CDATA[simple form validation]]></category>
		<category><![CDATA[simple validation]]></category>
		<category><![CDATA[validation]]></category>
		<guid isPermaLink="false">http://devinrolsen.com/?p=220</guid>
		<description><![CDATA[Today I wanted to write a quick demonstration of how to do a simple form validation. Here you will learn how to make sure that certain form fields are filled before any data is allowed to be sent off.]]></description>
			<content:encoded><![CDATA[<p>Today I wanted to write a quick demonstration of how to do a very simple client side form validation.</p>
<p>There are two types of form validation, server-side and client side, today we will cover client side validation with JavaScript.</p>
<h3 style="margin:0px;">Example of simple form validation (<em>Click Submit</em>)</h3>
<form action="http://www.devinrolsen.com/" method="post" onsubmit="return validate();" name="simpleForm">
<div><label>First Name:</label></div>
<div>
<input name="firstName" type="text" /></div>
<div><label>Last Name:</label></div>
<div>
<input name="lastName" type="text" /></div>
<div><label>Comment:</label></div>
<div><textarea cols="64" rows="8" name="message"></textarea></div>
<input type="submit" value="Submit" style="margin-left:345px;" />
</form>
<p><script type="text/javascript">function validate(){if(document.simpleForm.firstName.value == "" || document.simpleForm.lastName.value == "" || document.simpleForm.message.value == ""){alert("Please fill out all fields before clicking submit!");return false;} return false; }</script><br />
Ok lets start with a blank document:</p>
<pre>&lt;DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Simple Form Validation&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>In your body tags add the following simple form:</p>
<pre>&lt;form action="http://www.devinrolsen.com/" method="post" onsubmit="return validate();" name="simpleForm"&gt;
    &lt;label&gt;First Name:&lt;/label&gt;
    &lt;input type="text" name="firstName" /&gt;&lt;br /&gt;
    &lt;label&gt;Last Name:&lt;/label&gt;
    &lt;input type="text" name="lastName" /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;label&gt;Comment:&lt;/label&gt;
    &lt;br /&gt;
    &lt;textarea rows="8" cols="64" name="message"&gt;&lt;/textarea&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;input type="submit" value="Submit" style="margin-left:345px;" /&gt;
&lt;/form&gt;</pre>
<p>Ok first thing to point out with our simple form is that the form tag its self. The form tag has a on submit event of &#8220;return validate();&#8221; that is awaiting the return of either true or false from the function validate().</p>
<p>The second thing I would like to point out is that we gave our form a name of &#8220;simpleForm&#8221;. We give our form a name so that we can reference to it much quicker in our JavaScript &#8220;validate()&#8221; function that we will cover here in a second.</p>
<p>Moving onto the actual JavaScript, add the following to your documents header tags:</p>
<pre>&lt;script type="text/javascript"&gt;
function validate()
{
    if()
    {
    }
}
&lt;/script&gt;</pre>
<p>Great, here we are forming our validate() function and in this function we are going to create a simple condition that checks each of our form fields to validate if their values are empty or not.</p>
<p>Lets point to our first form element like so:</p>
<pre>&lt;script type="text/javascript"&gt;
function validate()
{
    if(document.simpleForm.firstName.value == "")
    {
    }
}
&lt;/script&gt;</pre>
<p>We first point to our document, then to the name of our form &#8220;simpleForm&#8221;, and then to the name of our first form element &#8220;firstName&#8221;. Once we are pointing to the first form element, we check its value to see if indeed its value is empty or not (== &#8220;&#8221;).</p>
<p>Its that simple!</p>
<p>Now lets point to the other two form elements (lastName and message) to bring validation them as well. We can extend our conditional statement to the rest of our form elements by using whats called &#8220;Logical Operators&#8221; like so:</p>
<pre>&lt;script type="text/javascript"&gt;
function validate()
{
    if(document.simpleForm.firstName.value == "" ||
    document.simpleForm.lastName.value == "" ||
    document.simpleForm.message.value == "")
    {
    }
}
&lt;/script&gt;</pre>
<p>Notice how we are using the &#8220;||&#8221; between each form elements we point to? Basically we are saying &#8220;if firstName element value is equal to empty, OR (||) lastName element is equal to empty, OR (||) message element is equal to empty, then do the following&#8221;.</p>
<p>By using the &#8220;||&#8221; OR logical operators we can extend our condition to as many form elements as we like. There are more logical operators that you can <a href="http://www.w3schools.com/JS/js_comparisons.asp" target="_blank">read about here</a>.</p>
<p>Great so now that we have extended out validation condition to check our three elements value&#8217;s, lets move on to the part of the function that cancels the form from being submitted if indeed one or more form element is empty like so:</p>
<pre>function validate(){
    if(document.simple_form.firstName.value == "" ||
    document.simple_form.lastName.value == "" ||
    document.simple_form.message.value == "")
    {
        alert("Please fill out all fields before clicking submit!");
        return false;
    }
}</pre>
<p>The first thing we want to do is inform the user that we must have all form elements filled out before it will be submitted. We do this by using the JavaScript altert to send our reminder to the user. Next we use &#8220;return false;&#8221; after altering our message to stop the form submitting and allow the user to correct their error.</p>
<p>And that&#8217;s it!</p>
<p>So with our simple condition we have pointed to each of our forms elements and peeked at its value. If the value of any of our form elements is equal to empty or rather nothing, we begin to alert a reminder to the user and halt the form from submitting to allow the user to correct the error. If all form fields pass our simple validation condition then our form continues to submit as normal.</p>
<p>Thanks everyone.</p>
<p>Devin R. Olsen</p>
<h3>THE BELOW FORM IS NOT A DEMO!!</h3>
]]></content:encoded>
			<wfw:commentRss>http://www.devinrolsen.com/simple-javascript-form-validation/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>JavaScript / Pure CSS Hide and Display Content</title>
		<link>http://www.devinrolsen.com/javascript-css-hide-display-content/</link>
		<comments>http://www.devinrolsen.com/javascript-css-hide-display-content/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 08:02:06 +0000</pubDate>
		<dc:creator>Devin R. Olsen</dc:creator>
				<category><![CDATA[JavaScript Tutorials]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[display hide content javascript css]]></category>
		<category><![CDATA[hide display]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[javascript css hide display]]></category>
		<guid isPermaLink="false">http://devinrolsen.com/?p=211</guid>
		<description><![CDATA[Ok today I am going to extent our pure CSS hide and display method a little bit and add a few extra behavior controls. Basically I was requested quite a few times to keep displaying our content even after our mouse has hovered off our hide and display elements.]]></description>
			<content:encoded><![CDATA[<p><strong>NOTE: If you have not read or downloaded the pure CSS version, this tutorial will not apply to you. I strongly suggest that you first read or at least download the <a title="Pure CSS Hide and Display Content" href="http://devinrolsen.com/css-hide-and-display-content/">pure CSS version here</a>, before trying to implement this update.</strong></p>
<p>Ok today I am going to extent our pure CSS hide and display method a little bit and add a few extra behavior controls. Basically I was requested quite a few times to keep displaying our content even after our mouse has hovered off our hide and display elements.</p>
<p>Here is an example of our pure CSS version mixed with Javascript to achieve the above(<strong><em>hover over one of the below tabs</em></strong>):</p>
<div id="contentBox">
<ul>
<li>
<div class="titleCell"><strong>Home</strong></div>
<ul>
<li>
<h1>Home Content</h1>
<p>Hi welcome to the live demonstration of the content display and hide method of presenting content to your visitors. This method is sometimes also called content switcher because each tab that you hover over displays content that is only relevant to that particular tab.</p>
<p>This is a great way to divide your content up into sections that the user can reference to quickly instead of scrolling through large amounts of content to find what they might be looking for. The best part of this method is that even though the content is dived up into parts for the visitors, the search engines see this content as a whole and have no knowledge that you are running a hide and display method to your visitors. Its the best of both worlds, user friendly and search engine friendly.</li>
</ul>
</li>
<li>
<div class="titleCell"><strong>About</strong></div>
<ul>
<li>
<h1>About Content</h1>
<p>Often in web development you find the need to divide your content into parts that is best for visitors and crawlers to find that particular content. One good case of this is a web site navigation menu that only allows for a visitor to see a topics submenu links when the user hovers over that topics button. Or if you have a image gallery and a visitor only sees one image upon hovering over that images thumb nail version. This was my need that brought me to develop this version of a content hide and display.</p>
<p>What makes this method of content hide and display or content switcher is the fact that it uses pure CSS and it is compatible with the following browsers.</p>
<p>IE5.5, IE6, IE7, IE8</p>
<p>Firefox</p>
<p>Safari</p>
<p>I created this method out of need and do not consider it to be the best solution to be found out on the net. However this is my solution that I want to share with you so if you like this method or feel like you might be able to improve this method feel free to do so. Please send me a comment or contact me here and let me know if you have improved or tweaked this method because I am always willing to learn new ways to expand my methods.</li>
</ul>
</li>
<li>
<div class="titleCell"><strong>Contact</strong></div>
<ul>
<li>
<h1>Contact Content</h1>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr,  sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr,  sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</li>
</ul>
</li>
<li>
<div class="titleCell"><strong>FAQ</strong></div>
<ul>
<li>
<h1>FAQ Content</h1>
<p>[<strong>Q</strong>] Is this a completely pure css method?</p>
<p>[<strong>A</strong>] In my opinion yes but some might argue because there is a JavaScript .htc file I use in this method. The .htc file is used to fix that 20% of users who still browse with IE6 and below that cant support CSS2 pseudo hover class.</p>
<p>[<strong>Q</strong>] Well How come we have to use JavaScript if this is a pure CSS method?</p>
<p>[<strong>A</strong>] IE6 and below do not support pure CSS methods for elements hover states. With the JavaScript .htc file we give IE6 and below the ability to have the pseudo hover class and us to write pure CSS methods. If the visitor to your site is using IE7 and up or any other browser out there this method will work and they will simply ignore this JavaScript .htc file.</p>
<p>[<strong>Q</strong>] Why should we care about IE6 and below?</p>
<p>[<strong>A</strong>] Because the percent of users who surf the net with IE6 and below make up of 20% of all internet users. That&#8217;s a huge amount of traffic you might want this method to work with as well.</p>
<p>[<strong>Q</strong>] Ok IE6 and below has 20% of internet users, but what about the people who have JavaScript turned off?</p>
<p>[<strong>A</strong>] If the visitor is using anything other than IE6 and below then the javascript is ignored and insignificant. The percent of users who surf the net with JavaScript turned off is about 9%. So 9% of that 20% who still use IE6 and below are the ones that this method will not work for.</p>
<p>Say you have 5000 visitors in one day.</p>
<p><strong>5000 &#8211; 20% = 1000</strong> visitors who use IE6 and below</p>
<p><strong>1000 &#8211; 9% = 360</strong> visitors use IE6 and below with JavaScript Turned off.</p>
<p>Those 360 visitors will be able to view this method if they simply turn on JavaScript.</p>
<p>The rest of the 4640 visitors will be just fine.</li>
</ul>
</li>
</ul>
</div>
<p>With this script you may have noticed that you are not adding any actual script references to any of our elements, meaning no actual JavaScript resides in our document what so ever.</p>
<p>This is great for search engines that still get confused with JavaScript and even references in elements. Also with no JavaScript references to our elements, we can rest assure that if the user has JavaScript turned off, then our method indeed gracefully degrades back to our original CSS version.</p>
<p>Ok to implement this script and achieve the above version, <a title="CSS / Javascript Hide Display Script" href="http://devinrolsen.com/wp-content/themes/typebased/demos/javascript/hide-display-content/hideDisplay.zip">download a copy this script here</a>.</p>
<p>Once you have downloaded a copy of the script, extract it from the zip file and link it to our desired document&#8217;s header with script tags like the following:</p>
<pre>&lt;script type="text/javascript" src="hideDisplay.js"&gt;&lt;/script&gt;</pre>
<p><strong>(src=&#8221;")</strong> is pointing to the location to where the script file lives either relatively or absolute to the document.</p>
<p>Ok next there are a few variables you are allowed to edit at the begriming of our script that I suggest you take a look at first. The variables range from the name of the main containers id to hover status button background colors and close button text.</p>
<pre>var mainContainer = "contentBox"; //ID NAME OF OUR MAIN CONTAINER
var closeBtn = "[CLOSE]"; //CLOSE BUTTON DISPLAYED TEXT
var overColor = "#fff"; //COLOR OF HOVERED TAB
var offColor = "#999"; //COLOR OF CLOSED TAB</pre>
<p>Last we want to add one more CSS style rule to our CSS hide display. This rule is for our close button&#8217;s style and structure.</p>
<pre>.closeBtn{
height:20px;
position:absolute;
top:-20px;
width:100%;
cursor:pointer;
text-align:right;
left:0px;
}</pre>
<p>This gives our &#8220;close button&#8221; a position of absolute in order to break out of our documents structured flow and always be position to the top right of our content hide and display when content is being displayed.</p>
<p>And that&#8217;s it everybody, painless no? Good Enjoy!</p>
<p>Devin R. Olsen<br />
<script src="http://devinrolsen.com/wp-content/themes/typebased/demos/javascript/hide-display-content/hideDisplay.js" type="text/javascript"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devinrolsen.com/javascript-css-hide-display-content/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Learning Basic JavaScript Faster Than Ever!</title>
		<link>http://www.devinrolsen.com/learning-basics-of-javascript/</link>
		<comments>http://www.devinrolsen.com/learning-basics-of-javascript/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 08:00:36 +0000</pubDate>
		<dc:creator>Devin R. Olsen</dc:creator>
				<category><![CDATA[JavaScript Tutorials]]></category>
		<category><![CDATA[basic javascript fast]]></category>
		<category><![CDATA[basics of javascript]]></category>
		<category><![CDATA[beginner javascript]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[learn basic javascript]]></category>
		<category><![CDATA[learn javascript fast]]></category>
		<guid isPermaLink="false">http://devinrolsen.com/?p=208</guid>
		<description><![CDATA[Basiclly there are three areas that JavaScript can be broken down into for one to gather a great grasp of just the basics. The three areas are as follows:]]></description>
			<content:encoded><![CDATA[<p>Before we begin to learn and practices with JavaScript, it’s going to make things a lot smoother if we are all using the same document setup. so for this tutorial I recommend you to practice with the following blank document.</p>
<pre>&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;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;JavaScript 101&lt;/title&gt;
&lt;script type="text/javascript"&gt;
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>Notice that in the above blank documents header tags we have script tags(<strong>&lt;script type=&#8221;text/javascript&#8221;&gt;&lt;/script&gt;</strong>). This area is where we will be practicing all our JavaScript, so please reference this area as our JavaScript only area.</p>
<p>Let’s begin shall we?</p>
<p>Basiclly there are three areas that JavaScript can be broken down into for one to gather a great grasp of just the basics. The three areas are as follows:</p>
<p><strong>- Variables</strong></p>
<p><strong>- Functions</strong></p>
<p><strong>- Conditions</strong></p>
<h2>Variables</h2>
<p>A variable is a place to store information. You can store numbers or text in a JavaScript variable. Remember back in middle school when we learned  basic algebra and worked on stuff like this?</p>
<pre>5 + 5 = x</pre>
<p><strong>x</strong> is obviously equal to 10, so in JavaScript we can basically stored this number of 10 into a variable called <strong>x</strong> that we can reference to and use later on. Once we have stored the number of 10 into a variable called <strong>x</strong>, we could use it in another formula like this.</p>
<pre>x-5 = y</pre>
<p>Oh no, we now have two variables!</p>
<p>We have<strong> x</strong> variable that stores our number of 10, and now another variable called <strong>y</strong> that uses our <strong>x</strong> variable, minuses 5,  equaling 5. So again we have two variables one called <strong>x</strong> that has a number of 10 stored in it, and now another called <strong>y</strong> that has a number of 5 stored in it.</p>
<p>Ok let’s stop looking at <strong>creepy math</strong> shall we, I never liked it anyways. All I  want to do is really drive the point home that with JavaScript variables we can store information into them so we may use the stored information at a later time.</p>
<p>Great, so what’s a JavaScript variable look like?</p>
<p>In JavaScript you must always state that you are about to create a variable by using:</p>
<pre><strong>var</strong></pre>
<p>&#8220;<strong>var</strong>&#8221; stands for variable and again every time we want to store some kind of information into a variable, we must start with &#8220;<strong>var</strong>&#8220;.<br />
Next we give our variable a name, this name is how we can reference to the variable  at a later time  by simply calling only its name.</p>
<pre><strong>var</strong> firstVariable</pre>
<p>Ok now that we have  created a new variable, and given this newly created variable a name, we have to store some sort of information into it. Storing information into a variable is called assigning values and here is what it would look like.</p>
<pre><strong>var</strong> firstVariable = "This is my first JavaScript varible!";</pre>
<p>Here we simply use the equals sign  to equal our varible to this little bit of text.</p>
<p>Text is called a string of text, in JavaScript strings of text must always be surrounded by quotes while numbers do not. Ok last thing is that we <strong>ALWAYS</strong> close off our variables with a semi-colon &#8220;<strong>;</strong>&#8221; to end our statement of &#8220;<strong>var</strong>&#8220;.</p>
<p>That wasn’t so bad now was it?</p>
<h2>Functions</h2>
<p>A function is like a processor that uses our variables to perform desired results. You can think of a JavaScript function like this.</p>
<p>We as humans, always have ideas and thoughts, and  these ideas or thoughts would be  like JavaScript variables. A function is like the computer, we use the computer to process these ideas and thoughts out for us. So again functions are always being fed variables or working with them to perform or process results out to us. Simple as that.</p>
<p>So what would a function look like? Functions, like variables must also be stated in order to be created but using &#8220;<strong>function</strong>&#8221; like so.</p>
<pre>function firstFunction()
{
}</pre>
<p>After  &#8220;function&#8221; we assign our function a name followed by parentheses. This is a standard way to set up a function and these parentheses are for extending our functions &#8220;variable flow&#8221; that we will talk about here in a moment.</p>
<p>After our parentheses, we have an open and close curly bracket and in here is where we use our variable to perform or rather process out our results.</p>
<p>Let’s come up with something we can process with our first function.  Let’s make two variables and store some numbers in them.</p>
<pre>function firstFunction()
{
  <strong>var</strong> firstVariable = 10;
  <strong>var</strong> secondVariable = 6;
}</pre>
<p>Great now let’s try and find the difference between these two numbers, how would we go about doing this?</p>
<p>Simple, yet another variable.</p>
<pre>function firstFunction()
{
  <strong>var</strong> firstVariable = 10;
  <strong>var</strong> secondVariable = 6;
  <strong>var</strong> <strong>difference = firstVariable - secondariable;</strong>
}</pre>
<p>Our third variable is called &#8220;difference&#8221; and its equaling its self to ( firstVariable &#8211; the secondVariable).</p>
<p>Ok, now that we have fed our function all the information it needs to process out some results,  how do we relay these results back out to the user?</p>
<p>One way to output results is to use the built-in feature of JavaScript called &#8220;alert&#8221;. The &#8220;alert&#8221; feature will take a variable or string of text and alert it out to a user in a pop-up box.</p>
<p>Let try using the &#8220;alert&#8221; feature to relay our processed variables out to us.</p>
<pre>function firstFunction()
{
  <strong>var</strong> firstVaribile = 10;
  <strong>var</strong> secondVaribile = 6;
  <strong>var</strong> difference = firstVariable - secondVariable;
  <strong>alert(difference);</strong>
}</pre>
<p>We have added the &#8220;alert&#8221; declaration to our function,  then parentheses that contains a reference to our &#8220;difference&#8221; variable followed by a semi-colon.</p>
<p>Now that we have our function ready to be executed we have to add a button or some sort of way to actually execute our function. So add this button to our document.</p>
<pre>&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;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;JavaScript 101&lt;/title&gt;
&lt;script type="text/javascript"&gt;
function firstFunction()
{
  <strong>var</strong> firstVaribile = 10;
  <strong>var</strong> secondVaribile = 6;
  <strong>var</strong> difference = firstVaribile - secondVaribile;
  <strong>alert(difference);</strong>
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;input type="button" value="Click Me" onclick="firstFunction()"/&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>Ok so in this new button, we have an attribute called &#8220;onclick&#8221; and we equal it to our firstFunction(). This is one of many ways of how to declare your function to being to process and executed. Save this document and run it, and click the button.</p>
<p>Awesome you have created your first script folks!!</p>
<p>Now, remember how when we created this function we created two parentheses that I said I would cover in a bit. Let talk more about  these parentheses and how they can help us.</p>
<p>In our firstFunciton() we created our  variables and alerted our results out, but this is a very liner method to use functions. Meaning, our function can be provided variables  that reside outside of our function to then still process out results to us. Being able to send variables to a function is a vital part of a function, simply because it literally makes the data flow a two-way street instead of a liner avenue of variables and results.</p>
<p>How the heck can we send variables to a function?</p>
<p>Simple, in our parentheses you state the variables name that we are going to want to use down in our curly brackets. Then any element acting as our trigger for executing our function, would  be where we pass a value or rather information into our awaiting variable and function.</p>
<p>Lets tweak our firstFunction() just a bit to better see what I am talking about.</p>
<pre>function firstFunction(<strong>firstVariable</strong>, <strong>secondVariable</strong>)
{
  <strong>var</strong> difference = firstVariable - secondVariable;
  <strong>alert</strong>(difference);
}</pre>
<p>Ok because we are now sending our variables to our function form another source, the variables them self do not need to be  using the &#8220;var&#8221; simply because this method creates a temporary storing location, not a true storing location for variables.</p>
<p>Ok lets tweak our html documents button &#8220;onclick&#8221;.</p>
<pre>&lt;input type="button" value="Click Me" onclick="firstFunction('10','6')"/&gt;</pre>
<p>If you haven’t noticed, in our &#8220;onclick&#8221; we still point to our firstFunction() but here we assign these external variable values to our awaiting function. Here the number ten represents the variable &#8220;firstVariable&#8221; and the number six still represents the variable &#8220;secondVariable&#8221;  Now the values are no longer residing within our actual function so you can send many different values to our function to receive many diffrent results. You can test it if you like, play with the number values in the &#8220;onclick&#8221; too.</p>
<h2>Conditions</h2>
<p>Ok so we have learned that we can create variables and store information in them. Also we learned that functions are constantly being fed our variables to process out desired results. We even learned how to process variables within a function or send variables to a function. Logically we must ask out self, &#8220;How can we give our functions even more room to process our results of any given situation not just value?&#8221;.</p>
<p>There are plenty of built-in features to JavaScript that really expand the diversity of how information is process in a function, but most widely use is called conditional statements.</p>
<p>Giving conditions to functions  means we get to be a bit more divers in how our variables are in fact being processed, a clause if you will.</p>
<p>Basically a simple conditional statement will look like the following.</p>
<pre>if()
{}
else
{}</pre>
<p>If something meets or fails our requirements do this, else do that, is what a conditional statement is saying. A conditional statement must always begin with the “<strong>if</strong>” clause followed by parentheses that will hold our <strong>deciding factor</strong> and then a pair of curly brackets.</p>
<p>In this first set of curly brackets we begin to process our variables and results &#8220;<strong>if</strong>&#8221; we either meet or fail our deciding factor depending on how the factor is set up. However there is always two sides to any deciding factor, so this is where the else portion comes in and gives an alternative process to our deciding factor.  First stating &#8220;<strong>else</strong>&#8221; and then another pair of curly brackets is the second half of a conditional statement. In this second pair of curly brackets we hold the flip side to our deciding factor and how our variables will be processed. Ok let’s make a quick conditional statement in our firstFunction().</p>
<pre>function firstFunction(firstVariable, secondVariable)
{
  <strong>var</strong> difference = firstVariable - secondVariable;
  if(difference == 4)
  {
    <strong>alert</strong>(difference);
  }
  else
  {
    <strong>alert</strong>("Sorry we expected something diffrent!");
  }
}</pre>
<p>Ok so in our conditional statement you can see that we make our deciding factor to be.</p>
<p>&#8220;<strong>If</strong> the variable &#8220;difference&#8221; is = to the number 4, then alert out the &#8220;difference&#8221; to our user, <strong>else</strong> alert our a sorry message&#8221;.</p>
<p>So if in our clicked button, we change any of the two variables we will get alerted this sorry message. Try it out yourself.</p>
<p>One last thing to talk about is the conditional statement before wrapping up this lesson is the alternative ways of using the conditional statements.</p>
<p>What do you do if your one function needs to have a whole array of conditions of how data might be processed? Well we are allowed two ways, one is nesting statements like so.</p>
<pre><strong>var</strong> difference = firstVariable - secondVariable;
if(difference == 4)
{
<strong>alert</strong>(difference);
}
else
{
      if(difference == 6)
      {
        <strong>alert</strong>(difference);
      }
      else
      {
              if(difference == 8)
              {
                <strong>alert</strong>(difference);
              }
              else
              {
                <strong>alert</strong>("Sorry we expected something different!");
              }
      }
}</pre>
<p>Here we have nested two conditional statements within  our “else” clauses, to meet an array of deciding factors for different numbers our &#8220;difference&#8221; variable is expected to be. Again if our &#8220;difference&#8221; variable will not meet any of the deciding factors will get alerted our sorry message.</p>
<p>The other method and more standard is not to nest your statements, but harness something called the &#8220;<strong>else if</strong>&#8220;. Here are the same conditions as above, but now using the &#8220;else if&#8221;.</p>
<pre><strong>var</strong> difference = firstVariable - secondVariable;
if(difference == 4)
{
  <strong>alert</strong>(difference);
}
<strong>else if</strong>(difference == 6)
{
  <strong>alert</strong>(difference);
}
<strong>else if</strong>(difference == 8)
{
  <strong>alert</strong>(difference);
}
else
{
  <strong>alert</strong>("Sorry we expected something different!");
}</pre>
<p>Ok so this is a lot cleaner if you ask me, and easy to maintain. Just like a regular conditional statement you have the opening if-clause and ending else clause, but here we introduce between the two the &#8220;<strong>else if</strong>&#8221; conditions to break out of our nested habits.</p>
<p>Ok so today we not only learned what a variable is and what it is for, but also how to feed it to a function. We learned about functions and receiving variables in functions and a JavaScript feature called alert to present our results to our viewers. We even learned about conditional statements and how they extend our ability&#8217;s to be more diverse in our functions processing.</p>
<p>And that&#8217;s your JavaScript 101 crash course everyone!</p>
<p>Thanks.</p>
<p><strong>Devin R. Olsen</strong></p>
<h3><a href="http://www.devinrolsen.com/intermediate-javascript-tutorial/">Lesson Two: Learning Intermediate JavaScript Faster Than Ever!</a></h3>
]]></content:encoded>
			<wfw:commentRss>http://www.devinrolsen.com/learning-basics-of-javascript/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
