<?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>Redink Design &#187; Javascript</title>
	<atom:link href="http://redinkdesign.net/category/programming/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://redinkdesign.net</link>
	<description>Good code is its own best documentation</description>
	<lastBuildDate>Tue, 10 Aug 2010 15:34:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>jQuery vs. MooTools</title>
		<link>http://redinkdesign.net/programming/jquery-vs-mootools/</link>
		<comments>http://redinkdesign.net/programming/jquery-vs-mootools/#comments</comments>
		<pubDate>Wed, 20 May 2009 14:53:39 +0000</pubDate>
		<dc:creator>Ashwin Surajbali</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA["Most people getting started with JavaScript these days are faced with the challenging task of picking a library to use, or at least which one to learn first. If you're working for a company chances are they have already chosen a framework for you, in which case the point is somewhat moot. If this is the case and they've chosen MooTools and you're used to jQuery, then this article might still be of some use to you. "

Written by Aaron Newton

Article here:
http://jqueryvsmootools.com]]></description>
			<content:encoded><![CDATA[<p>&#8220;Most people getting started with JavaScript these days are faced with the challenging task of picking a library to use, or at least which one to learn first. If you&#8217;re working for a company chances are they have already chosen a framework for you, in which case the point is somewhat moot. If this is the case and they&#8217;ve chosen MooTools and you&#8217;re used to jQuery, then this article might still be of some use to you. &#8221;</p>
<p>Written by Aaron Newton</p>
<p>Article here:</p>
<p>http://jqueryvsmootools.com/</p>
]]></content:encoded>
			<wfw:commentRss>http://redinkdesign.net/programming/jquery-vs-mootools/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple Field Validator/Highlighter</title>
		<link>http://redinkdesign.net/programming/simple-field-validatorhighlighter/</link>
		<comments>http://redinkdesign.net/programming/simple-field-validatorhighlighter/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 11:42:28 +0000</pubDate>
		<dc:creator>Ashwin Surajbali</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[This is a simple script that will highlight required fields on a form. It requires no libraries and is just one simple function that accepts an array of field id's that are required.<br /><br />

Code:<br />
<code>

function checkRequiredFields(fieldIdsArray){

	var fields = fieldIdsArray;
	var errorThrown = false;

	for (var i = 0; i &#60; fields.length; i++){
		var obj = document.getElementById(fields[i]);
		if (obj.value == &#39;&#39; &#124;&#124; obj.value == null){
			obj.style.border = &#39;1px solid red&#39;;
			obj.onfocus = function(){ this.style.border = &#39;1px solid #999999&#39;};
]]></description>
			<content:encoded><![CDATA[<p>This is a simple script that will highlight required fields on a form. It requires no libraries and is just one simple function that accepts an array of field id&#8217;s that are required.</p>
<p><strong>Code:</strong></p>
<pre class="brush: jscript;">
function checkRequiredFields(fieldIdsArray){

	var fields = fieldIdsArray;
	var errorThrown = false;

	for (var i = 0; i &lt; fields.length; i++){
		var obj = document.getElementById(fields[i]);
		if (obj.value == '' || obj.value == null){
			obj.style.border = '1px solid red';
			obj.onfocus = function(){ this.style.border = '1px solid #999999'};
			errorThrown = true;
		}
	}

	if (errorThrown){
		alert('Please fill in required fields.');
		return false;
	}

	return true;

}
</pre>
<p><strong>Example:</strong></p>
<pre class="brush: jscript;">
var requiredFields = new Array('field_1', 'field_2');

function checkRequiredFields(fieldIdsArray){

	var fields = fieldIdsArray;
	var errorThrown = false;

	for (var i = 0; i &lt; fields.length; i++){
		var obj = document.getElementById(fields[i]);
		if (obj.value == '' || obj.value == null){
			obj.style.border = '1px solid red';
			obj.onfocus = function(){ this.style.border = '1px solid #999999'};
			errorThrown = true;
		}
	}

	if (errorThrown){
		alert('Please fill in required fields.');
		return false;
	}

	return true;

}

&lt;input type=&quot;text&quot; name=&quot;field_1&quot; id=&quot;field_1&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;field_2&quot; id=&quot;field_2&quot;&gt;
&lt;input type=&quot;button&quot; onclick=&quot;checkRequiredFields(requiredFields);&quot;&gt;
OR
&lt;input type=&quot;button&quot; onclick=&quot;checkRequiredFields(['field_1','field_2']);&quot;&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://redinkdesign.net/programming/simple-field-validatorhighlighter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove HTML Elements Dynamically</title>
		<link>http://redinkdesign.net/programming/remove-html-elements-dynamically/</link>
		<comments>http://redinkdesign.net/programming/remove-html-elements-dynamically/#comments</comments>
		<pubDate>Thu, 08 May 2008 13:10:48 +0000</pubDate>
		<dc:creator>Ashwin Surajbali</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[A simple javascript snippet to remove HTML elements dynamically.

<code>

       function removeElement(elementId){
		var itemToBeRemoved = document.getElementById(elementId);
		var parent = itemToBeRemoved.parentNode;
		parent.removeChild(itemToBeRemoved);
	};

</code]]></description>
			<content:encoded><![CDATA[<p>A simple javascript snippet to remove HTML elements dynamically.</p>
<pre class="brush: jscript;">
function removeElement(elementId){
	var itemToBeRemoved = document.getElementById(elementId);
	var parent = itemToBeRemoved.parentNode;
	parent.removeChild(itemToBeRemoved);
};
</pre>
]]></content:encoded>
			<wfw:commentRss>http://redinkdesign.net/programming/remove-html-elements-dynamically/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Auto-complete Text Box</title>
		<link>http://redinkdesign.net/programming/auto-complete-text-box/</link>
		<comments>http://redinkdesign.net/programming/auto-complete-text-box/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 15:06:40 +0000</pubDate>
		<dc:creator>Ashwin Surajbali</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[
function showPopup(textBox, className){

	// grab the textbox object
	var textbox = document.getElementById(textBox);

	// get the textboxes parent
	var parent = textbox.parentNode;


	// check to see if this popup is already on screen
	var popup = document.getElementById(textBox + '_popup');


	if (!popup) {
		// we don't have a popup, lets create one

		// create popup div
		var popup = document.createElement('div');
		// give it a unique id
		popup.id = textBox + '_popup';

		// attach css if passed in]]></description>
			<content:encoded><![CDATA[<p>function showPopup(textBox, className){</p>
<p>	// grab the textbox object<br />
	var textbox = document.getElementById(textBox);</p>
<p>	// get the textboxes parent<br />
	var parent = textbox.parentNode;</p>
<p>	// check to see if this popup is already on screen<br />
	var popup = document.getElementById(textBox + &#8216;_popup&#8217;);</p>
<p>	if (!popup) {<br />
		// we don&#8217;t have a popup, lets create one</p>
<p>		// create popup div<br />
		var popup = document.createElement(&#8216;div&#8217;);<br />
		// give it a unique id<br />
		popup.id = textBox + &#8216;_popup&#8217;;</p>
<p>		// attach css if passed in<br />
		popup.className = className || &#8216;popup&#8217;;</p>
<p>		// set it&#8217;s left location<br />
		popup.style.left = textbox.offsetLeft;</p>
<p>		// set it&#8217;s top location<br />
		popup.style.top = textbox.offsetHeight + textbox.offsetTop;</p>
<p>		// make sure it&#8217;s absolute<br />
		popup.style.position = &#8216;absolute&#8217;;</p>
<p>		// attach it to the text boxes parent node<br />
		parent.appendChild(popup);</p>
<p>	}else{<br />
		popup.style.display = &#8216;block&#8217;;<br />
	}</p>
<p>	// attach an event to remove the popup once it loses focus<br />
	document.onclick = function(){<br />
		if (popup){<br />
			popup.style.display = &#8216;none&#8217;;<br />
			delete popup;<br />
		}<br />
	};</p>
<p>	// give it some content<br />
	popup.innerHTML += textbox.value + &#8220;<br />&#8220;;</p>
<p>}</p>
<p>.popupClass{<br />
height: 150px;<br />
	width: 150px;<br />
	border: 1px solid black;<br />
	background: yellow;<br />
	overflow: auto;<br />
}</p>
<p>This is a very simple script to lead you in the right direction towards making an auto-complete textbox, similar to Google Suggest (http://www.google.com/webhp?complete=1&amp;hl=en). This script does not need any fancy framework to work. </p>
<p>Example: </p>
<p><code><br />
function showPopup(textBox, className){</p>
<p>	// grab the textbox object<br />
	var textbox = document.getElementById(textBox);</p>
<p>	// get the textboxes parent<br />
	var parent = textbox.parentNode;</p>
<p>	// check to see if this popup is already on screen<br />
	var popup = document.getElementById(textBox + '_popup');</p>
<p>	if (!popup) {<br />
		// we don't have a popup, lets create one</p>
<p>		// create popup div<br />
		var popup = document.createElement('div');<br />
		// give it a unique id<br />
		popup.id = textBox + '_popup';</p>
<p>		// attach css if passed in<br />
		popup.className = className || 'popup';</p>
<p>		// set it's left location<br />
		popup.style.left = textbox.offsetLeft;</p>
<p>		// set it's top location<br />
		popup.style.top = textbox.offsetHeight + textbox.offsetTop;</p>
<p>		// make sure it's absolute<br />
		popup.style.position = 'absolute';</p>
<p>		// attach it to the text boxes parent node<br />
		parent.appendChild(popup);</p>
<p>	}else{<br />
		popup.style.display = 'block';<br />
	}</p>
<p>	// attach an event to remove the popup once it loses focus<br />
	document.onclick = function(){<br />
		if (popup){<br />
			popup.style.display = 'none';<br />
			delete popup;<br />
		}<br />
	};</p>
<p>	// give it some content<br />
	popup.innerHTML += textbox.value + "<br />";</p>
<p>}<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://redinkdesign.net/programming/auto-complete-text-box/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
