<?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>www.mattginsberg.net &#187; JavaScript Tutorials</title>
	<atom:link href="http://www.mattginsberg.net/category/javascript-tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mattginsberg.net</link>
	<description></description>
	<lastBuildDate>Wed, 12 May 2010 18:23:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tutorial: Draggable Div with Open and Close Links.</title>
		<link>http://www.mattginsberg.net/tutorial-draggable-div-with-open-and-close-links/</link>
		<comments>http://www.mattginsberg.net/tutorial-draggable-div-with-open-and-close-links/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 04:01:53 +0000</pubDate>
		<dc:creator>Matt Ginsberg</dc:creator>
				<category><![CDATA[CSS Tutorials]]></category>
		<category><![CDATA[JavaScript Tutorials]]></category>
		<category><![CDATA[Tutorials / How To's]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[Close]]></category>
		<category><![CDATA[Drag]]></category>
		<category><![CDATA[Open]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.mattginsberg.net/?p=1697</guid>
		<description><![CDATA[If you read my first draggable div tutorial, you would know that I had planned to show you how to add a close and open function for this. So within this tutorial, I plan to show you what the old code looked like, and how to add the two extra functions. At the bottom of the tutorial you will see a link to view it in action.]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-1698 aligncenter" title="banner2" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/09/banner22.jpg" alt="banner2" width="500" height="100" /></p>
<p style="text-align: left;">If you read my first <a href="http://www.mattginsberg.net/tutorial-draggable-div/">draggable div tutorial</a>, you would know that I had planned to show you how to add a close and open function for this. So within this tutorial, I plan to show you what the old code looked like, and how to add the two extra functions. At the bottom of the tutorial you will see a link to view it in action.</p>
<p style="text-align: left;">
<p style="text-align: left;"><span style="text-decoration: underline;"><strong>Here is the full code from the previous tutorial:<br />
</strong></span><a href="http://www.mattginsberg.net/dragdiv" target="_blank">See it in action.</a><span style="text-decoration: underline;"><strong> </strong></span></p>
<blockquote><p><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;<br />
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;<br />
&lt;title&gt;Untitled Document&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;style type="text/css"&gt;<br />
#maindiv{<br />
z-index:10;<br />
background: #FFC;<br />
color:#000;<br />
width: 400px;<br />
height: 250px;<br />
position: absolute;<br />
top: 50px;<br />
left: 50px;<br />
padding:10px;<br />
}<br />
#header{<br />
color:#000000;<br />
background: #CCC;<br />
padding:5px;<br />
text-align:center;<br />
}<br />
#header:hover{<br />
color:#fff;<br />
background:#000;<br />
text-align:center;<br />
}<br />
&lt;/style&gt;<br />
&lt;script language="javascript"&gt;<br />
var drag=0;<br />
var xdif=0;<br />
var ydif=0;<br />
var initx="50px";<br />
var inity="50px";<br />
function begindrag(event){<br />
if(drag==0){<br />
floatingd = document.getElementById("maindiv");<br />
if(floatingd.style.left==""){<br />
floatingd.style.left=initx;<br />
}<br />
if(floatingd.style.top==""){<br />
floatingd.style.top=inity;<br />
}<br />
prex=floatingd.style.left.replace(/px/,"");<br />
prey=floatingd.style.top.replace(/px/,"");<br />
drag=1;<br />
xdif=event.clientX-prex;<br />
ydif=event.clientY-prey;<br />
}else{<br />
drag=0;<br />
}<br />
}<br />
function mousepos(event){<br />
floatingd = document.getElementById("maindiv");<br />
if(drag==1){<br />
floatingd.style.left = event.clientX-xdif+"px";<br />
floatingd.style.top = event.clientY-ydif+"px";;<br />
}<br />
}<br />
&lt;/script&gt;<br />
&lt;/HEAD&gt;<br />
&lt;BODY onMouseMove="mousepos(event)" &gt;<br />
&lt;div id='maindiv'&gt;<br />
&lt;div id='header' onclick="begindrag(event)" style="cursor:move"&gt;click in this region then move your mouse around&lt;/div&gt;<br />
&lt;br /&gt;<br />
Once you move it, then click on the mouse again to release it.... very easy and cool. <img src='http://www.mattginsberg.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  This is perfect for advertising, or a website with stats. &lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</code></p></blockquote>
<p>Now, it is very simple to add the open and close functions to this. <span style="text-decoration: underline;"><strong><em><br />
You want to add this into the Javascript code</em></strong></span>:</p>
<blockquote><p><code> function closeit(){document.getElementById("maindiv").style.display="none"}<br />
function loadwindow(){document.getElementById("maindiv").style.display="block"}<br />
</code></p></blockquote>
<p><strong>Your <span style="text-decoration: underline;">full Javascript code</span> should look like this:</strong></p>
<blockquote><p><code>&lt;script language="javascript"&gt;<br />
var drag=0;<br />
var xdif=0;<br />
var ydif=0;<br />
var initx="50px";<br />
var inity="50px";<br />
function begindrag(event){<br />
if(drag==0){<br />
floatingd = document.getElementById("maindiv");<br />
if(floatingd.style.left==""){<br />
floatingd.style.left=initx;<br />
}<br />
if(floatingd.style.top==""){<br />
floatingd.style.top=inity;<br />
}<br />
prex=floatingd.style.left.replace(/px/,"");<br />
prey=floatingd.style.top.replace(/px/,"");<br />
drag=1;<br />
xdif=event.clientX-prex;<br />
ydif=event.clientY-prey;<br />
}else{<br />
drag=0;<br />
}<br />
}<br />
function mousepos(event){<br />
floatingd = document.getElementById("maindiv");<br />
if(drag==1){<br />
floatingd.style.left = event.clientX-xdif+"px";<br />
floatingd.style.top = event.clientY-ydif+"px";;<br />
}<br />
}<br />
function closeit(){<br />
document.getElementById("maindiv").style.display="none"<br />
}<br />
function loadwindow(){<br />
document.getElementById("maindiv").style.display="block"<br />
}<br />
&lt;/script&gt;</code></p></blockquote>
<p><strong>You now want to add the close div link into your HTML. To close the div, use the following HTML code:</strong><br />
<em><span style="text-decoration: underline;">Make sure to enter this code inside of the maindiv.</span></em></p>
<blockquote><p><code> &lt;p onClick="closeit()" style="cursor:pointer"&gt;close this div&lt;/p&gt;<br />
</code></p></blockquote>
<p><strong>You now want to add the open div link into your HTML. To open the div, use the following HTML code:</strong><br />
<em><span style="text-decoration: underline;">Make sure this code is not inside of the maindiv. </span></em></p>
<blockquote><p><code> &lt;div onclick="loadwindow()" style="cursor:pointer"&gt;Load Div&lt;/div&gt;<br />
</code></p></blockquote>
<p><strong>Here is the full code with the open and close links:</strong></p>
<blockquote><p><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;<br />
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;<br />
&lt;title&gt;Draggable Div&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;style type="text/css"&gt;<br />
#maindiv{<br />
z-index:10;<br />
background: #FFC;<br />
color:#000;<br />
width: 400px;<br />
height: 250px;<br />
position: absolute;<br />
top: 50px;<br />
left: 50px;<br />
padding:10px;<br />
}<br />
#header{<br />
color:#000000;<br />
background: #CCC;<br />
padding:5px;|<br />
text-align:center;<br />
}<br />
#header:hover{<br />
color:#fff;<br />
background:#000;<br />
text-align:center;<br />
}<br />
&lt;/style&gt;<br />
&lt;script language="javascript"&gt;<br />
var drag=0;<br />
var xdif=0;<br />
var ydif=0;<br />
var initx="50px";<br />
var inity="50px";<br />
function begindrag(event){<br />
if(drag==0){<br />
floatingd = document.getElementById("maindiv");<br />
if(floatingd.style.left==""){<br />
floatingd.style.left=initx;<br />
}<br />
if(floatingd.style.top==""){<br />
floatingd.style.top=inity;<br />
}<br />
prex=floatingd.style.left.replace(/px/,"");<br />
prey=floatingd.style.top.replace(/px/,"");<br />
drag=1;<br />
xdif=event.clientX-prex;<br />
ydif=event.clientY-prey;<br />
}else{<br />
drag=0;<br />
}<br />
}<br />
function mousepos(event){<br />
floatingd = document.getElementById("maindiv");<br />
if(drag==1){<br />
floatingd.style.left = event.clientX-xdif+"px";<br />
floatingd.style.top = event.clientY-ydif+"px";;<br />
}<br />
}<br />
function closeit(){<br />
document.getElementById("maindiv").style.display="none"<br />
}<br />
function loadwindow(){<br />
document.getElementById("maindiv").style.display="block"<br />
}<br />
&lt;/script&gt;<br />
&lt;/HEAD&gt;<br />
&lt;BODY onMouseMove="mousepos(event)" &gt;<br />
&lt;div id='maindiv'&gt;<br />
&lt;div id='header' ononclick="begindrag(event)" style="cursor:move"&gt;click in this region then move your mouse around&lt;/div&gt;<br />
&lt;p&gt;&lt;br /&gt;<br />
Once you move it, then click on the mouse again to release it.... very easy and cool. <img src='http://www.mattginsberg.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  This is perfect for advertising, or a website with stats. &lt;/p&gt;<br />
&lt;p&gt;&amp;nbsp;&lt;/p&gt;<br />
&lt;p&gt;&amp;nbsp;&lt;/p&gt;<br />
&lt;p onClick="closeit()" style="cursor:pointer"&gt;close this div&lt;/p&gt;<br />
&lt;/div&gt;<br />
&lt;div onclick="loadwindow()" style="cursor:pointer"&gt;Load Div&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</code></p></blockquote>
<p><a href="http://www.mattginsberg.net/ocdragdiv" target="_blank">See it in action.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattginsberg.net/tutorial-draggable-div-with-open-and-close-links/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tutorial: Draggable Div</title>
		<link>http://www.mattginsberg.net/tutorial-draggable-div/</link>
		<comments>http://www.mattginsberg.net/tutorial-draggable-div/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 04:01:06 +0000</pubDate>
		<dc:creator>Matt Ginsberg</dc:creator>
				<category><![CDATA[CSS Tutorials]]></category>
		<category><![CDATA[JavaScript Tutorials]]></category>
		<category><![CDATA[Tutorials / How To's]]></category>
		<category><![CDATA[Div]]></category>
		<category><![CDATA[Grad]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.mattginsberg.net/?p=1665</guid>
		<description><![CDATA[Creating a div is, as you already (should) know, is very easy. A div is a great way to layout a website for many reasons. In this tutorial, I will show you how to create a div that lays on top of your content, and then the user can move it around the screen as they see fit.Also, you can see how to add a link within your website that will open the div and a link to close it. ]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="alignnone size-full wp-image-1685" title="banner" src="http://www.mattginsberg.net/blog/wp-content/uploads/2009/09/banner4.jpg" alt="banner" width="500" height="100" /></p>
<p style="text-align: left;">Creating a div is, as you already (should) know, is very easy. A div is a great way to layout a website for many reasons. In this tutorial, I will show you how to create a div that lays on top of your content, and then the user can move it around the screen as they see fit. Also, you can see how to add a link within your website that will open the div and a link to close it. If you want to learn more, <a href="http://www.mattginsberg.net/tutorial-draggable-div-with-open-and-close-links">read this tutorial</a>.</p>
<p style="text-align: left;">The first thing you want to do is create a new HTML file, or use a file that you are working with right now. You want to add the following CSS to the stylesheet. If you do have the stylesheet, be sure not to include the &lt;style type=&#8221;text/css&#8221;&gt; and the &lt;/style&gt;. If you do not have an external stylesheet, add the below after the head section and before the body section.</p>
<p style="text-align: left;">
<blockquote><p><code><br />
&lt;style type="text/css"&gt;<br />
#maindiv{<br />
z-index:10;<br />
background: #FFC;<br />
color:#000;<br />
width: 400px;<br />
height: 250px;<br />
position: absolute;<br />
top: 50px;<br />
left: 50px;<br />
padding:10px;<br />
}<br />
#header{<br />
color:#000000;<br />
background: #CCC;<br />
padding:5px;<br />
text-align:center;<br />
}<br />
#header:hover{<br />
color:#fff;<br />
background:#000;<br />
text-align:center;<br />
}<br />
&lt;/style&gt;</code></p></blockquote>
<p><strong>Next you want to add the Javascript. Below is the code.</strong></p>
<blockquote><p><code><br />
&lt;script language="javascript"&gt;<br />
var drag=0;<br />
var xdif=0;<br />
var ydif=0;<br />
var initx="50px";<br />
var inity="50px";<br />
function begindrag(event){<br />
if(drag==0){<br />
floatingd = document.getElementById("maindiv");<br />
if(floatingd.style.left==""){<br />
floatingd.style.left=initx;<br />
}<br />
if(floatingd.style.top==""){<br />
floatingd.style.top=inity;<br />
}<br />
prex=floatingd.style.left.replace(/px/,"");<br />
prey=floatingd.style.top.replace(/px/,"");<br />
drag=1;<br />
xdif=event.clientX-prex;<br />
ydif=event.clientY-prey;<br />
}else{<br />
drag=0;<br />
}<br />
}<br />
function mousepos(event){<br />
floatingd = document.getElementById("maindiv");<br />
if(drag==1){<br />
floatingd.style.left = event.clientX-xdif+"px";<br />
floatingd.style.top = event.clientY-ydif+"px";;<br />
}<br />
}<br />
&lt;/script&gt;<br />
</code></p></blockquote>
<p><strong>Now you want to put the following code in the &lt;body&gt; script like so:</strong></p>
<blockquote><p><code><br />
&lt;<strong>body onMouseMove="mousepos(event)"</strong> &gt;<br />
</code></p></blockquote>
<p><strong>And <span style="text-decoration: underline;">finally</span>, enter the following HTML code into the body section of your website.</strong></p>
<blockquote><p><code><br />
&lt;div id='maindiv'&gt;<br />
&lt;div id='header' onclick="begindrag(event)" style="cursor:move"&gt;click in this region then move your mouse around&lt;/div&gt;<br />
&lt;br /&gt;<br />
Once you move it, then click on the mouse again to release it.... very easy and cool. This is perfect for advertising, or a website with stats. &lt;/div&gt;</code></p></blockquote>
<p><span style="text-decoration: underline;"><strong>Here is the full code:</strong></span></p>
<blockquote><p><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;<br />
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;<br />
&lt;title&gt;Untitled Document&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;style type="text/css"&gt;<br />
#maindiv{<br />
z-index:10;<br />
background: #FFC;<br />
color:#000;<br />
width: 400px;<br />
height: 250px;<br />
position: absolute;<br />
top: 50px;<br />
left: 50px;<br />
padding:10px;<br />
}<br />
#header{<br />
color:#000000;<br />
background: #CCC;<br />
padding:5px;<br />
text-align:center;<br />
}<br />
#header:hover{<br />
color:#fff;<br />
background:#000;<br />
text-align:center;<br />
}<br />
&lt;/style&gt;<br />
&lt;script language="javascript"&gt;<br />
var drag=0;<br />
var xdif=0;<br />
var ydif=0;<br />
var initx="50px";<br />
var inity="50px";<br />
function begindrag(event){<br />
if(drag==0){<br />
floatingd = document.getElementById("maindiv");<br />
if(floatingd.style.left==""){<br />
floatingd.style.left=initx;<br />
}<br />
if(floatingd.style.top==""){<br />
floatingd.style.top=inity;<br />
}<br />
prex=floatingd.style.left.replace(/px/,"");<br />
prey=floatingd.style.top.replace(/px/,"");<br />
drag=1;<br />
xdif=event.clientX-prex;<br />
ydif=event.clientY-prey;<br />
}else{<br />
drag=0;<br />
}<br />
}<br />
function mousepos(event){<br />
floatingd = document.getElementById("maindiv");<br />
if(drag==1){<br />
floatingd.style.left = event.clientX-xdif+"px";<br />
floatingd.style.top = event.clientY-ydif+"px";;<br />
}<br />
}<br />
&lt;/script&gt;<br />
&lt;/HEAD&gt;<br />
&lt;BODY onMouseMove="mousepos(event)" &gt;<br />
&lt;div id='maindiv'&gt;<br />
&lt;div id='header' onclick="begindrag(event)" style="cursor:move"&gt;click in this region then move your mouse around&lt;/div&gt;<br />
&lt;br /&gt;<br />
Once you move it, then click on the mouse again to release it.... very easy and cool. <img src='http://www.mattginsberg.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  This is perfect for advertising, or a website with stats. &lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</code></p></blockquote>
<p><a href="http://www.mattginsberg.net/dragdiv" target="_blank">See it in action.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattginsberg.net/tutorial-draggable-div/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adding CAPTCHA to PHP email form using JavaScript.</title>
		<link>http://www.mattginsberg.net/captcha-to-php-email-form/</link>
		<comments>http://www.mattginsberg.net/captcha-to-php-email-form/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 22:19:35 +0000</pubDate>
		<dc:creator>Matt Ginsberg</dc:creator>
				<category><![CDATA[JavaScript Tutorials]]></category>

		<guid isPermaLink="false">http://www.mattginsberg.net/?p=587</guid>
		<description><![CDATA[This is a test for smoothgallery.]]></description>
			<content:encoded><![CDATA[<p style="TEXT-ALIGN: center"><img class="aligncenter size-full wp-image-629" title="captcha" src="http://www.mattginsberg.net/blog/wp-content/uploads/2008/12/captcha.jpg" alt="captcha" width="475" height="150" /></p>
<p>To put it simply a captcha works by generating a random string, writing it to an image, then storing the string inside of a session or cookie or by some other method. These are great when you want to have some extra security in your forms. They also help from all of the spam emails you get from your website forms.</p>
<p>Instead of typing out the entire script, take a look at this great premade <a href="http://www.archreality.com/jcap/jcap.zip">script</a>. It was made by Jonathan Feaster and he posted it on his website. He named it Jcap. You can view the website <a href="http://www.archreality.com/jcap/" target="_blank">here</a>. Everything is premade and all you need to do is drag the files into your server. Do a few tweaks with the HTML and your good to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattginsberg.net/captcha-to-php-email-form/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tutorial: Highlight table row with the onClick function.</title>
		<link>http://www.mattginsberg.net/highlight-table-row/</link>
		<comments>http://www.mattginsberg.net/highlight-table-row/#comments</comments>
		<pubDate>Sat, 06 Dec 2008 01:01:30 +0000</pubDate>
		<dc:creator>Matt Ginsberg</dc:creator>
				<category><![CDATA[JavaScript Tutorials]]></category>

		<guid isPermaLink="false">http://www.mattginsberg.net/?p=593</guid>
		<description><![CDATA[Have you ever have a very long table and it got really annoying for you and your visitors to look at the information? With this very simple script, your aggrevation is now over. Lets get started.
Insert this JavaScript code into the &#60;head&#62;&#60;/head&#62; of your HTML document.

&#60;script&#62;
var preEl ;
var orgBColor;
var orgTColor;
function HighLightTR(el, backColor,textColor){
if(typeof(preEl)!='undefined') {
preEl.bgColor=orgBColor;
try{ChangeTextColor(preEl,orgTColor);}catch(e){;}
}
orgBColor = el.bgColor;
orgTColor = el.style.color;
el.bgColor=backColor;
try{ChangeTextColor(el,textColor);}catch(e){;}
preEl = el;
}
function ChangeTextColor(a_obj,a_color){ ;
for (i=0;i&#60;a_obj.cells.length;i++)
a_obj.cells(i).style.color=a_color;
}
&#60;/script&#62;

 
Now it is time to add the table to the &#60;body&#62;&#60;/body&#62; of your HTML.

&#60;table width="450" border="1"&#62;
&#60;tr&#62;
&#60;td colspan="6"&#62;Highlight Row onClick.&#60;/td&#62;
&#60;/tr&#62;
&#60;tr&#62;
&#60;td style="font-weight:bold"&#62;TEST&#60;/td&#62;
&#60;td style="font-weight:bold"&#62;TEST&#60;/td&#62;
&#60;td style="font-weight:bold"&#62;TEST&#60;/td&#62;
&#60;td style="font-weight:bold"&#62;TEST&#60;/td&#62;
&#60;td style="font-weight:bold"&#62;TEST&#60;/td&#62;
&#60;td style="font-weight:bold"&#62;TEST&#60;/td&#62;
&#60;/tr&#62;
&#60;tr&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;/tr&#62;
&#60;tr&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;/tr&#62;
&#60;tr&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;/tr&#62;
&#60;tr&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;td&#62;test&#60;/td&#62;
&#60;/tr&#62;
&#60;/table&#62;


 
Now where you see &#60;tr&#62;, ...]]></description>
			<content:encoded><![CDATA[<p>Have you ever have a very long table and it got really annoying for you and your visitors to look at the information? With this very simple script, your aggrevation is now over. Lets get started.</p>
<p>Insert this <strong>JavaScript code </strong>into the <strong>&lt;head&gt;&lt;/head&gt;</strong> of your HTML document.</p>
<blockquote><p><code><br />
&lt;script&gt;<br />
var preEl ;<br />
var orgBColor;<br />
var orgTColor;<br />
function HighLightTR(el, backColor,textColor){<br />
if(typeof(preEl)!='undefined') {<br />
preEl.bgColor=orgBColor;<br />
try{ChangeTextColor(preEl,orgTColor);}catch(e){;}<br />
}<br />
orgBColor = el.bgColor;<br />
orgTColor = el.style.color;<br />
el.bgColor=backColor;<br />
try{ChangeTextColor(el,textColor);}catch(e){;}<br />
preEl = el;<br />
}<br />
function ChangeTextColor(a_obj,a_color){ ;<br />
for (i=0;i&lt;a_obj.cells.length;i++)<br />
a_obj.cells(i).style.color=a_color;<br />
}<br />
&lt;/script&gt;</code></p>
</blockquote>
<p> <span id="more-593"></span></p>
<p>Now it is time to add the <strong>table </strong>to the <strong>&lt;body&gt;&lt;/body&gt;</strong> of your HTML.</p>
<blockquote><p><code><br />
&lt;table width="450" border="1"&gt;<br />
&lt;tr&gt;<br />
&lt;td colspan="6"&gt;Highlight Row onClick.&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td style="font-weight:bold"&gt;TEST&lt;/td&gt;<br />
&lt;td style="font-weight:bold"&gt;TEST&lt;/td&gt;<br />
&lt;td style="font-weight:bold"&gt;TEST&lt;/td&gt;<br />
&lt;td style="font-weight:bold"&gt;TEST&lt;/td&gt;<br />
&lt;td style="font-weight:bold"&gt;TEST&lt;/td&gt;<br />
&lt;td style="font-weight:bold"&gt;TEST&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;/table&gt;<br />
</code></p>
</blockquote>
<p> </p>
<p>Now where you see &lt;tr&gt;, insert the following code <strong>before </strong>the &gt;:</p>
<blockquote><p><code><br />
onClick="HighLightTR(this,'#ccc','#000000');"<br />
<strong>The first set of numbers is for the highlight behind the text. The second set is for the text.</strong></code></p>
</blockquote>
<p> </p>
<p>You will now have something like this:</p>
<blockquote><p><code><br />
&lt;table width="450" border="1"&gt;<br />
&lt;tr&gt;<br />
&lt;td colspan="6"&gt;Highlight Row onClick.&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td style="font-weight:bold"&gt;TEST&lt;/td&gt;<br />
&lt;td style="font-weight:bold"&gt;TEST&lt;/td&gt;<br />
&lt;td style="font-weight:bold"&gt;TEST&lt;/td&gt;<br />
&lt;td style="font-weight:bold"&gt;TEST&lt;/td&gt;<br />
&lt;td style="font-weight:bold"&gt;TEST&lt;/td&gt;<br />
&lt;td style="font-weight:bold"&gt;TEST&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr onClick="HighLightTR(this,'#ccc','#000000');"&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr onClick="HighLightTR(this,'#ccc','#000000');"&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr onClick="HighLightTR(this,'#ccc','#000000');"&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr onClick="HighLightTR(this,'#ccc','#000000');"&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;td&gt;test&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;/table&gt;<br />
</code></p>
</blockquote>
<p> </p>
<p>Here is the final code put together:</p>
<blockquote>
<div><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;<br />
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;<br />
&lt;title&gt;Untitled Document&lt;/title&gt;<br />
&lt;script&gt;<br />
var preEl ;<br />
var orgBColor;<br />
var orgTColor;<br />
function HighLightTR(el, backColor,textColor){<br />
if(typeof(preEl)!='undefined') {<br />
preEl.bgColor=orgBColor;<br />
try{ChangeTextColor(preEl,orgTColor);}catch(e){;}<br />
}<br />
orgBColor = el.bgColor;<br />
orgTColor = el.style.color;<br />
el.bgColor=backColor;</code></div>
<div><code>try{ChangeTextColor(el,textColor);}catch(e){;}<br />
preEl = el;<br />
}</code></div>
<div><code>function ChangeTextColor(a_obj,a_color){ ;<br />
for (i=0;i&lt;a_obj.cells.length;i++)<br />
a_obj.cells(i).style.color=a_color;<br />
}<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;table width="425" border=0 align=center cellpadding="2" cellspacing="2"&gt;<br />
&lt;caption&gt;<br />
click to see effect<br />
&lt;/caption&gt;<br />
&lt;tr&gt;<br />
&lt;th&gt;&lt;strong&gt;Test&lt;/strong&gt;&lt;/th&gt;<br />
&lt;th&gt;&lt;strong&gt;Test&lt;/strong&gt;&lt;/th&gt;<br />
&lt;th&gt;&lt;strong&gt;Test&lt;/strong&gt;&lt;/th&gt;<br />
&lt;th&gt;&lt;strong&gt;Test&lt;/strong&gt;&lt;/th&gt;<br />
&lt;th&gt;&lt;strong&gt;Test&lt;/strong&gt;&lt;/th&gt;<br />
&lt;th&gt;&lt;strong&gt;Test&lt;/strong&gt;&lt;/th&gt;<br />
&lt;tr onClick="HighLightTR(this,'#ccc','#000000');" &gt;<br />
&lt;td align=left&gt;test&lt;/td&gt;<br />
&lt;td align=left&gt;test&lt;/td&gt;<br />
&lt;td align=left&gt;test&lt;/td&gt;<br />
&lt;td align=left&gt;test&lt;/td&gt;<br />
&lt;td align=left&gt;test&lt;/td&gt;<br />
&lt;td align=left&gt;test&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr onClick="HighLightTR(this,'#345','#000000');" &gt;<br />
&lt;td align=left&gt;test&lt;/td&gt;<br />
&lt;td align=left&gt;test&lt;/td&gt;<br />
&lt;td align=left&gt;test&lt;/td&gt;<br />
&lt;td align=left&gt;test&lt;/td&gt;<br />
&lt;td align=left&gt;test&lt;/td&gt;<br />
&lt;td align=left&gt;test&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr onClick="HighLightTR(this,'#543','#000000');" &gt;<br />
&lt;td align=left&gt;test&lt;/td&gt;<br />
&lt;td align=left&gt;test&lt;/td&gt;<br />
&lt;td align=left&gt;test&lt;/td&gt;<br />
&lt;td align=left&gt;test&lt;/td&gt;<br />
&lt;td align=left&gt;test&lt;/td&gt;<br />
&lt;td align=left&gt;test&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;/table&gt;</code></div>
<div><code>&lt;/body&gt;<br />
&lt;/html&gt;</code></div>
<div><code> </code></div>
<div><code> </code></div>
<p><code> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p></code></p>
</blockquote>
<p> </p>
<p><a href="http://www.mattginsberg.net/highlight.html" target="_blank">See it in action!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattginsberg.net/highlight-table-row/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
