<?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>Grey Fuzz &#187; Javascript code snippets</title>
	<atom:link href="http://www.greyfuzz.com/category/geeky-stuff/javascript-code-snippets/feed" rel="self" type="application/rss+xml" />
	<link>http://www.greyfuzz.com</link>
	<description>Come get some!</description>
	<lastBuildDate>Thu, 29 Jul 2010 22:04:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Javascript &#8211; check/uncheck all form checkboxes</title>
		<link>http://www.greyfuzz.com/2006/09/javascript-checkuncheck-all-form-checkboxes</link>
		<comments>http://www.greyfuzz.com/2006/09/javascript-checkuncheck-all-form-checkboxes#comments</comments>
		<pubDate>Thu, 21 Sep 2006 22:21:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript code snippets]]></category>

		<guid isPermaLink="false">http://blog.captivereefing.com/2006/09/21/javascript-checkuncheck-all-form-checkboxes/</guid>
		<description><![CDATA[After searching around the net looking for an example snippet of javascript that would check or uncheck all of a series of checkboxes on a form&#8230; the results from Google were good, however each &#8216;example&#8217; assumed that you I actually had a good understanding of what you were reading or that you I might actually [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://www.greyfuzz.com/2006/09/javascript-checkuncheck-all-form-checkboxes";
		digg_bgcolor = "";
		digg_skin = "";
		digg_window = "";
		digg_title = "Javascript+%26%238211%3B+check%2Funcheck+all+form+checkboxes";
		digg_media = "";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><p>After searching around the net looking for an example snippet of javascript that would check or uncheck all of a series of checkboxes on a form&#8230; the results from Google were good, however each &#8216;example&#8217; assumed that <del datetime="2006-09-21T22:14:26+00:00">you</del> I actually had a good understanding of what you were reading or that <del datetime="2006-09-21T22:14:26+00:00">you</del> I might actually read it instead of just pasting the pieces you liked in&#8230; Obviously I did the latter and after 20 minutes of pounding my head on the keyboard figured out what I was doing wrong&#8230;</p>
<p>So for all of you code slammers, this one is for you.</p>
<p>[code]<br />
    <script language="JavaScript"></p>
<p>    function checkall()
    {
    for(i=0; i<document .FormName.elements.length; i++)
    {
    if(document.FormName.elements[i].type=="checkbox")
    {
    document.FormName.elements[i].checked=true;
    }
    }
    }</p>
<p>    function uncheckall()
    {
    for(i=0; i<document.FormName.elements.length; i++)
    {
    if(document.FormName.elements[i].type=="checkbox")
    {
    document.FormName.elements[i].checked=false;
    }
    }
    }</p>
<p>    </script><br />
[/code]</p>
<p>Simple enough, look through each form element and either mark them checked or unchecked depending on the function being called.</p>
<p>And of course in your markup</p>
<p>[code]<br />
<a href="javascript: void(0);" onclick="javascript: checkall();">Check All</a> / <a href="javascript: void(0);" onclick="javascript: uncheckall();">Uncheck All</a><br />
[/code]</p>
<p>And now where I went wrong.  If you actually read the JavaScript you'll see the lines</p>
<p><em>document.FormName.elements.....</em></p>
<p>Well, FormName <strong>must be specified!</strong>  Look at your markup where<br />
[code]</p>
<form name="get_form_data" method="POST" action="....... blah blah blah<br />
[/code]</p>
<p>if you change the javascript lines to read<br />
document.<em>get_form_data.elements.....</p>
<p>Life will be bliss and you can click check and uncheck all afternoon long and watch the little checkmarks magically appear and disappear from your forms.  Providing you with some entertainment while waiting for the impression of the keypad to subside from your forehead.
</p></form>
<p></document></script></p>
<p>------------------------------<br />
The <a href="http://www.envisionwebhosting.com/reviews/dotster-hosting.htm">dotster</a> offers a <a href="http://www.ispdir.net">high speed internet</a> service to its customers. The <a href="http://www.throughwalls.net/Rogers-Wireless.html">rogers wireless</a> phones are very popular among the phone services and is used many businesses. The businesses are constantly working out way to make their websites popular among the customers by having <a href="http://www.lucidseo.com">seo</a> services. The <a href="http://www.throughwalls.net/Sprint-Wireless.html">sprint wireless</a> uses the <a href="http://www.envisionwebhosting.com/reviews/startlogic-hosting.htm">startlogic</a> programming to produce efficient results for the customers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.greyfuzz.com/2006/09/javascript-checkuncheck-all-form-checkboxes/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Expanding List / Menu</title>
		<link>http://www.greyfuzz.com/2006/07/javascript-expanding-list-menu</link>
		<comments>http://www.greyfuzz.com/2006/07/javascript-expanding-list-menu#comments</comments>
		<pubDate>Fri, 28 Jul 2006 20:02:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript code snippets]]></category>

		<guid isPermaLink="false">http://blog.captivereefing.com/2006/07/28/javascript-expanding-list-menu/</guid>
		<description><![CDATA[An easy method to create an expanding list using javascript. I&#8217;ve incorporated the code into some server status pages to show or hide tables. Effective and clean looking. [code] ul { margin-top: 0px; margin-bottom:0px; } ul.expand { display: none; } li { list-style-type: none; display: block; } img { border: none; vertical-align: text-bottom; } function [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://www.greyfuzz.com/2006/07/javascript-expanding-list-menu";
		digg_bgcolor = "";
		digg_skin = "";
		digg_window = "";
		digg_title = "Javascript+Expanding+List+%2F+Menu";
		digg_media = "";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><p>An easy method to create an expanding list using javascript.  I&#8217;ve incorporated the code into some server status pages to show or hide tables.  Effective and clean looking.</p>
<p>[code]<br />
<html><br />
<head><br />
<title></title></p>
<style>
ul {  margin-top: 0px;  margin-bottom:0px; }</p>
<p>ul.expand { display: none; }</p>
<p>li { list-style-type: none; display: block; }</p>
<p>img {
  border: none;
  vertical-align:
  text-bottom;
}
</style>
<p><script>
function toggle(id)
{
  var L = document.getElementById("L"+id);
  var I = document.getElementById("I"+id);
  if (L.style.display == "" || L.style.display == "none") {
    L.style.display = "block";
    I.src = "opened.gif";
  }
  else {
    L.style.display = "none";
    I.src = "closed.gif";
  }
}
</script></p>
<p></head><br />
<body></p>
<h3>An Expanding List</h3>
<p>
Click on the red right-arrows to expand the list.<br />
Click on the green down-arrows to contract the list.
</p>
<li><img onclick="toggle(1)" id="I1" src="closed.gif"/>Topic A
<ul class="expand" id="L1">
<li><img src="fixed.gif" />Topic A1</li>
<li><img onclick="toggle(2)" id="I2" src="closed.gif"/>Topic A2
<ul class="expand" id="L2">
<li><img src="fixed.gif" />Topic A21</li>
<li><img src="fixed.gif" />Topic A22</li>
<li><img src="fixed.gif" />Topic A23</li>
</ul>
</li>
<li><img src="fixed.gif" />Topic A3</li>
</ul>
</li>
<li>
<img onclick="toggle(3)" id="I3" src="closed.gif"/>Topic B</p>
<ul class="expand" id="L3">
<li><img src="fixed.gif" />Topic B1</li>
<li><img src="fixed.gif" />Topic B2</li>
<li><img src="fixed.gif" />Topic B3</li>
</ul>
</li>
<p></body><br />
</html></p>
<p>and here is how it works.<br />
Timer Display</p>
<p>Animation, in its broadest sense means changing the content over time, usually withing small time intervals. In JavaScript, the key to animation is the setInterval function which causes a function to be called at periodic intervals.<br />
This is perhaps the most basic example illustrating the usage of the setInterval function. The current time and date can be read into a string using an operation something like this:</p>
<p>timedate = new Date();</p>
<p>What we want to do is to depict the "running" time in our browser, i.e., we want it updated every second with a new value. Here is the example:</p>
<p><html><br />
<head></p>
<p><script type="text/javascript">
<!--
function init()
{
  showDate();
  setInterval('showDate()', 1000);
}
function showDate()
{
  var time = document.getElementById("time");
  time.innerHTML = new Date();
}
// -->
</script><br />
</head><br />
<body onload="init();"></p>
<p>The current time and date on my system is:<br />
<span style="color:red" id="time"></span></p>
<p></body><br />
</html><br />
[/code]</p>
<p>Borrowed from http://www.cs.wcupa.edu/~rkline/Web/JavaScriptExamples.html</p>
]]></content:encoded>
			<wfw:commentRss>http://www.greyfuzz.com/2006/07/javascript-expanding-list-menu/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Collapsible Lists</title>
		<link>http://www.greyfuzz.com/2006/07/javascript-collapsible-lists</link>
		<comments>http://www.greyfuzz.com/2006/07/javascript-collapsible-lists#comments</comments>
		<pubDate>Fri, 07 Jul 2006 21:37:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript code snippets]]></category>

		<guid isPermaLink="false">http://blog.captivereefing.com/2006/07/07/javascript-collapsible-lists/</guid>
		<description><![CDATA[Javascript and DHTML can be used to make collapsible and expandable HTML lists that degrade cleanly (that is, are still usable for visitors who don&#8217;t have Javascript-enabled web browsers). Example This has been tested in Opera, Mozilla (Navigator) and Internet Explorer. Clicking on the arrows expands or collapses sections of the list: The code You [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://www.greyfuzz.com/2006/07/javascript-collapsible-lists";
		digg_bgcolor = "";
		digg_skin = "";
		digg_window = "";
		digg_title = "Javascript+Collapsible+Lists";
		digg_media = "";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><p>Javascript and DHTML can be used to make collapsible and expandable HTML lists that degrade cleanly (that is, are still usable for visitors who don&#8217;t have Javascript-enabled web browsers).<br />
Example</p>
<p>This has been tested in Opera, Mozilla (Navigator) and Internet Explorer. Clicking on the arrows expands or collapses sections of the list:</p>
<p>The code</p>
<p>You need to create images called closed.png and open.png to be used for collapsed and expanded lists respectively. When adding more lists, the id values for the img and ul elements must be changed, and the parameters in the call to toggle() in the image&#8217;s onClick value must be changed to these ids.</p>
<p>[code]</p>
<ul id="collapsibleList">
<li>
<script type="text/javascript">document.writeln('<img id="iBMImage" src="closed.png" width="15" height="8" alt="Open list" onClick="toggle(\'iBMImage\',\'iBMList\');"/>');
</script> IBM </li>
</ul>
<ul id="iBMList">
<li>80x86</li>
<li>Itanium</li>
</ul>
<li>
<script type="text/javascript">document.writeln('<img id="motorolaImage" src="closed.png" width="15" height="8" alt="Open list" onClick="toggle(\'motorolaImage\',\'motorolaList\');"/>');
</script> Motorola </li>
<ul id="motorolaList">
<li>680x0</li>
<li>PowerPC</li>
</ul>
<p><script type="text/javascript"> document.getElementById('collapsibleList').style.listStyle="none"; // remove list markers document.getElementById('iBMList').style.display="none"; // collapse list document.getElementById('motorolaList').style.display="none"; // collapse list // this function toggles the status of a list function toggle(image,list){
var listElementStyle=document.getElementById(list).style; if (listElementStyle.display=="none"){ listElementStyle.display="block"; document.getElementById(image).src="open.png"; document.getElementById(image).alt="Close list";
}
else{
listElementStyle.display="none"; document.getElementById(image).src="closed.png"; document.getElementById(image).alt="Open list";
}
}
</script><br />
[/code]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.greyfuzz.com/2006/07/javascript-collapsible-lists/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable right click with javascript</title>
		<link>http://www.greyfuzz.com/2006/05/disable-right-click-with-javascript</link>
		<comments>http://www.greyfuzz.com/2006/05/disable-right-click-with-javascript#comments</comments>
		<pubDate>Tue, 02 May 2006 19:39:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript code snippets]]></category>

		<guid isPermaLink="false">http://blog.captivereefing.com/2006/05/02/disable-right-click-with-javascript/</guid>
		<description><![CDATA[Though not able to stop anyone who really wants your source code, images, or other imbedded items, this will slow down some&#8230; disable right mouse click with a bit of JavaScript in your pages header [code] [/code]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://www.greyfuzz.com/2006/05/disable-right-click-with-javascript";
		digg_bgcolor = "";
		digg_skin = "";
		digg_window = "";
		digg_title = "Disable+right+click+with+javascript";
		digg_media = "";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><p>Though not able to stop anyone who really wants your source code, images, or other imbedded items, this will slow down some&#8230;  disable right mouse click with a bit of JavaScript in your pages header</p>
<p>[code]<br />
<head><br />
<script language=JavaScript>
<!--
var message="Function Disabled!";
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}
function clickNS4(e){
if (document.layers||document.getElementById&#038;&#038;!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&#038;&#038;!document.getElementById){
document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("alert(message);return false")
// -->
</script><br />
</head><br />
[/code]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.greyfuzz.com/2006/05/disable-right-click-with-javascript/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Close current browser window</title>
		<link>http://www.greyfuzz.com/2006/04/close-current-browser-window</link>
		<comments>http://www.greyfuzz.com/2006/04/close-current-browser-window#comments</comments>
		<pubDate>Thu, 27 Apr 2006 17:35:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript code snippets]]></category>

		<guid isPermaLink="false">http://blog.captivereefing.com/2006/04/27/close-current-browser-window/</guid>
		<description><![CDATA[Simple javascript to add a Close link to any page that will close the browser window the link resides in&#8230; good for popups and the like [code] click here [/code]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://www.greyfuzz.com/2006/04/close-current-browser-window";
		digg_bgcolor = "";
		digg_skin = "";
		digg_window = "";
		digg_title = "Close+current+browser+window";
		digg_media = "";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><p>Simple javascript to add a Close link to any page that will close the browser window the link resides in&#8230; good for popups and the like</p>
<p>[code]<br />
<a href="javascript:self.close()">click here</a><br />
[/code]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.greyfuzz.com/2006/04/close-current-browser-window/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
