<?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>Optimus Pete &#187; javascript</title>
	<atom:link href="http://tech.petegraham.co.uk/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://tech.petegraham.co.uk</link>
	<description>yes i love technology</description>
	<lastBuildDate>Wed, 25 Aug 2010 10:06:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>JS: Execute JavaScript on Page Load</title>
		<link>http://tech.petegraham.co.uk/2007/05/14/js-execute-javascript-on-page-load/</link>
		<comments>http://tech.petegraham.co.uk/2007/05/14/js-execute-javascript-on-page-load/#comments</comments>
		<pubDate>Mon, 14 May 2007 10:47:11 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[Website Development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://tech.petegraham.co.uk/2007/05/14/js-execute-javascript-on-page-load/</guid>
		<description><![CDATA[Recently I’ve been making an effort to improve my JavaScript skills, I’m not a JavaScript-Jedi yet but I have been picking up a few, tips, tricks and techniques.
One thing that I find extremely useful is using an init function to call other functions when the page has loaded. I have been using the nifty function [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I’ve been making an effort to improve my JavaScript skills, I’m not a JavaScript-Jedi yet but I have been picking up a few, tips, tricks and techniques.</p>
<p>One thing that I find extremely useful is using an init function to call other functions when the page has loaded. I have been using the nifty function below:</p>
<div class="igBar"><span id="ljavascript-4"><a href="#" onclick="javascript:showPlainTxt('javascript-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-4">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> WindowOnload<span style="color: #66cc66;">&#40;</span>f<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> prev=window.<span style="color: #000066;">onload</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">window.<span style="color: #000066;">onload</span>=<span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>prev<span style="color: #66cc66;">&#41;</span>prev<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; f<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>I save this function in a file called init.js which is then included in my HTML pages using:</p>
<div class="igBar"><span id="lhtml-5"><a href="#" onclick="javascript:showPlainTxt('html-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-5">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> xsrc=<span style="color: #ff0000;">"/js/init.js"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Functions can then be initialised by including the following in the HTML:</p>
<div class="igBar"><span id="ljavascript-6"><a href="#" onclick="javascript:showPlainTxt('javascript-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-6">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;script language=<span style="color: #3366CC;">"JavaScript"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;!--</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">WindowOnload<span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">a_function<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'Sdelete_date'</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">WindowOnload<span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">another_function<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'a_parameter'</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//--&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/script&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The above code is inline JavaScript which is often seen as being naughty, obviously you can save the same code to a separate file and include that instead.</p>
<p>I originally saw this technique <a href="http://blog.firetree.net/2005/07/17/javascript-onload/">here</a>. Alternative JS <a href="http://simonwillison.net/2004/May/26/addLoadEvent/">initialisation scripts</a> are available but so far this one has worked well for me, so I’ll be sticking with it.</p>
<p># Pete Graham</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.petegraham.co.uk/2007/05/14/js-execute-javascript-on-page-load/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JS: Unobtrusive Select All Checkboxes</title>
		<link>http://tech.petegraham.co.uk/2007/03/26/js-unobtrusive-select-all-checkboxes/</link>
		<comments>http://tech.petegraham.co.uk/2007/03/26/js-unobtrusive-select-all-checkboxes/#comments</comments>
		<pubDate>Mon, 26 Mar 2007 10:03:47 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Website Development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[unobtrusive]]></category>

		<guid isPermaLink="false">http://tech.petegraham.co.uk/2007/03/26/js-unobtrusive-select-all-checkboxes/</guid>
		<description><![CDATA[I wrote last week about how I’m trying to improve my JavaScript skills. As a small exercise I have written this function for unobtrusively selecting/deselecting checkboxes in a form.
PLAIN TEXT
JAVASCRIPT:




function selectAll&#40;box&#41;


&#123;


// get the elements name


var id = box.id;


var name = /^&#40;&#91;a-z&#93;+&#41;&#40;_select_all&#41;$/i.exec&#40;id&#41;;


&#160;


name = name&#91;1&#93;;


&#160;


re = new RegExp&#40;'^'+name+'_[0-9]+$'&#41;;


&#160;


// get the elements stauts


var state = box.checked;


&#160;


// get the [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote last week about how I’m <a href="http://tech.petegraham.co.uk/2007/03/20/my-volatile-relationship-with-javascript/">trying to improve my JavaScript</a> skills. As a small exercise I have written this function for unobtrusively selecting/deselecting checkboxes in a form.</p>
<div class="igBar"><span id="ljavascript-9"><a href="#" onclick="javascript:showPlainTxt('javascript-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-9">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> selectAll<span style="color: #66cc66;">&#40;</span>box<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// get the elements name</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> id = box.<span style="color: #006600;">id</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> <span style="color: #000066;">name</span> = <span style="color: #0066FF;">/^<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span>a-z<span style="color: #66cc66;">&#93;</span>+<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span>_select_all<span style="color: #66cc66;">&#41;</span>$/i</span>.<span style="color: #006600;">exec</span><span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066;">name</span> = <span style="color: #000066;">name</span><span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;color:#800000;">1</span><span style="color: #66cc66;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">re = <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'^'</span>+<span style="color: #000066;">name</span>+<span style="color: #3366CC;">'_[0-9]+$'</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// get the elements stauts</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> state = box.<span style="color: #006600;">checked</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// get the form element, search &quot;up&quot;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> form = box.<span style="color: #006600;">parentNode</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">while</span><span style="color: #66cc66;">&#40;</span>form.<span style="color: #006600;">nodeName</span>.<span style="color: #006600;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> != <span style="color: #3366CC;">"form"</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>!form.<span style="color: #006600;">parentNode</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000066; font-weight: bold;">break</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">form = form.<span style="color: #006600;">parentNode</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// search through forms children for email_ checkboxes</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span>i=<span style="color: #CC0000;color:#800000;">0</span>;i&lt;form.<span style="color: #006600;">elements</span>.<span style="color: #006600;">length</span>;i++<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>form.<span style="color: #006600;">elements</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">type</span>==<span style="color: #3366CC;">'checkbox'</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// Find checkbox for each member of the group:</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>re.<span style="color: #006600;">test</span><span style="color: #66cc66;">&#40;</span>form.<span style="color: #006600;">elements</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #000066;">name</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">form.<span style="color: #006600;">elements</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">checked</span> = state;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// onload stuff</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">window.<span style="color: #000066;">onload</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> email = document.<span style="color: #006600;">getElementById</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'email_select_all'</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">email.<span style="color: #006600;">onclick</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">return</span> selectAll<span style="color: #66cc66;">&#40;</span>email<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The Javascript will work on a HTML form like this</p>
<div class="igBar"><span id="lhtml-10"><a href="#" onclick="javascript:showPlainTxt('html-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-10">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/form.html"><span style="color: #000000; font-weight: bold;">&lt;form</span></a> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">"post"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- Select all check box --&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">&lt;input</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"email_select_all"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"checkbox"</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- list of check boxes --&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"checkbox"</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"email_1"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"1"</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"checkbox"</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"email_2"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"1"</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"checkbox"</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"email_3"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"1"</span>  /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"checkbox"</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"email_4"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"1"</span>  /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"submit"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"Send Message"</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/form&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>As long at the select all checkbox has an id of "something_select_all" and the checkboxes have id's of "something_"followed by a number then this will work. No inline Javascript is required all the JS can be put in a separate file.</p>
<p>Note: If any Javascript Gurus are reading that have pointers about how I could improve this function then please put your suggestions in the comments.</p>
<p># Pete Graham</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.petegraham.co.uk/2007/03/26/js-unobtrusive-select-all-checkboxes/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>My volatile relationship with Javascript</title>
		<link>http://tech.petegraham.co.uk/2007/03/20/my-volatile-relationship-with-javascript/</link>
		<comments>http://tech.petegraham.co.uk/2007/03/20/my-volatile-relationship-with-javascript/#comments</comments>
		<pubDate>Tue, 20 Mar 2007 17:55:00 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Website Development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://tech.petegraham.co.uk/2007/03/20/my-volatile-relationship-with-javascript/</guid>
		<description><![CDATA[I started work in web development in 2004 at this point in time JavaScript was hugely unpopular in terms of web trends, this is probably because it was mostly used for annoying pop-ups, animations and whole list of other horrendous Internet crimes. I can recall having a King Herod style culling of all JavaScript from [...]]]></description>
			<content:encoded><![CDATA[<p>I started work in web development in 2004 at this point in time JavaScript was hugely unpopular in terms of web trends, this is probably because it was mostly used for annoying pop-ups, animations and whole list of other horrendous Internet crimes. I can recall having a King Herod style culling of all JavaScript from the <a target="_blank" href="http://www.tcat.ac.uk">TCAT website</a>, my first main project.</p>
<p>Recently due to the popularity of AJAX web applications JavaScript’s popularity seems to have exploded again! I’ve had to brush up on my JavaScript skills for some of the User Interface work on <a target="_blank" href="http://phuser.com">phuser.com</a>. Whenever I do JavaScript development I never feel as comfortable as I do with PHP or CSS. It’s definitely the weakest weapon in my web-dev arsenal.</p>
<p>I think it’s time to put my JavaScript prejudices behind me and get my hands dirty with some serious JS development. Now I’m not a JavaScript novice, I’ve got a few DHTML tricks up my sleeve I learnt back in the day. However I rarely write my own JavaScript, if I need a function I’ll look for one someone else has written.</p>
<p>When I’ve needed to learn about Javascript in the past I’ve always find it surprisingly hard to find good quality decent resources (compared to other Web technologies). I shall be posting links to any JavaScript articles/tutorials that I find particularly useful on this blog.</p>
<p><span style="font-weight: bold">Articles</span></p>
<ul>
<li><a target="_blank" href="http://adactio.com/atmedia2005/"> Using JavaScript for good, not evil</a>: Good short intro to unobtrusive JavaScript</li>
<li><a target="_blank" href="http://alistapart.com/articles/behavioralseparation"> Behavoiral Separation</a>: Covers the gallery example of the previous article but more indept code explaination</li>
<li><a href="http://www.howtocreate.co.uk/tutorials/javascript/dombasics"> DOM nodes and tree</a>: Unsurprisingly this provides a good introduction to the DOM (Document Object Model)</li>
</ul>
<p># Pete Graham</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.petegraham.co.uk/2007/03/20/my-volatile-relationship-with-javascript/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>CSS tips and articles</title>
		<link>http://tech.petegraham.co.uk/2007/02/01/css-tips-and-articles/</link>
		<comments>http://tech.petegraham.co.uk/2007/02/01/css-tips-and-articles/#comments</comments>
		<pubDate>Thu, 01 Feb 2007 18:08:17 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Website Development]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://tech.petegraham.co.uk/2007/02/01/css-tips-and-articles/</guid>
		<description><![CDATA[I began teaching myself Cascading Style Sheets (CSS) in 2004 when I graduated from University and started work in website development. At the time it was difficult to find well written resources that thoroughly explained how various CSS techniques worked.
In the past few years, CSS adoption has increased dramatically. These days most high profile websites [...]]]></description>
			<content:encoded><![CDATA[<p>I began teaching myself Cascading Style Sheets (CSS) in 2004 when I graduated from University and started work in website development. At the time it was difficult to find well written resources that thoroughly explained how various CSS techniques worked.</p>
<p>In the past few years, CSS adoption has increased dramatically. These days most high profile websites use CSS rather than tables for their design. Although <a target="_blank" href="http://amazon.co.uk">amazon.co.uk</a> and <a target="_blank" href="http://news.bbc.co.uk">bbc news</a> still have partially table based layouts, naughty!</p>
<p>Thankfully they are now many excellent articles available on CSS. Yesterday while working my way though some bug fixes on <a target="_blank" href="http://phuser.com">phuser.com</a> I stumbled upon some brilliant ones that I hadn’t read before.</p>
<p>Emil Stenstrom has written an excellent article on how to <a target="_blank" href="http://friendlybit.com/css/cross-browser-strategies-for-css/">Cross-browser CSS</a> for your site. One tip I picked up is to start your CSS files with:</p>
<div class="igBar"><span id="lcss-13"><a href="#" onclick="javascript:showPlainTxt('css-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CSS:</span>
<div id="css-13">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">* <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span>: <span style="color: #cc66cc;color:#800000;">0</span>; <span style="color: #000000; font-weight: bold;">padding</span>: <span style="color: #cc66cc;color:#800000;">0</span>; <span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This will remove all default element stylings which can be a right pain in the @r$e when trying to get your site to render consistently cross browser. A clever little hack he suggests is the "star html" hack:</p>
<div class="igBar"><span id="lcss-14"><a href="#" onclick="javascript:showPlainTxt('css-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CSS:</span>
<div id="css-14">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">* html <span style="color: #cc00cc;">#element <span style="color: #66cc66;">&#123;</span></span> code; <span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This is valid CSS but only IE will apply "code" to "#element". I think its much cleaner than <a target="_blank" href="http://www.sitepoint.com/article/browser-specific-css-hacks">other browser hacks</a> I’ve seen. Many of his articles are well worth a read but I would especially recommend his guide on <a target="_blank" href="http://friendlybit.com/css/how-to-structure-large-css-files/">structuring large CSS files </a>. <a target="_blank" href="http://friendlybit.com/css/real-hackers-dont-use-css/">Real hackers don't use css</a> is more amusing than useful but still interesting.</p>
<p>For people wanting to learn more about CSS and web design techniques in general <a target="_blank" href="http://www.alistapart.com/">A List Apart</a> is well worth checking out. Also worth a mention is <a target="_blank" href="http://www.projectseven.com/tutorials/css/pvii_columns/index.htm">this fix</a> for the two columns with equal height layout, it uses Javascript instead of the normal background image fix.<br />
/* Pete Graham */</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.petegraham.co.uk/2007/02/01/css-tips-and-articles/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Curse you Internet Explorer!</title>
		<link>http://tech.petegraham.co.uk/2007/01/27/curse-you-internet-explorer/</link>
		<comments>http://tech.petegraham.co.uk/2007/01/27/curse-you-internet-explorer/#comments</comments>
		<pubDate>Sat, 27 Jan 2007 17:36:42 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://tech.petegraham.co.uk/2007/01/27/curse-you-internet-explorer/</guid>
		<description><![CDATA[I was pretty pleased with the code syntax highlighting plugin I installed yesterday, just before I was about to finish work I got the Blog up in IE6 Arrrggghhh! IE6 redenders the width of the main content column  smaller than Firefox and IE7, this causes the main content to be displayed below the content [...]]]></description>
			<content:encoded><![CDATA[<p>I was pretty pleased with the code <a href="http://tech.petegraham.co.uk/2007/01/26/sytax-highlighting-a-go-go/">syntax highlighting plugin</a> I installed yesterday, just before I was about to finish work I got the Blog up in IE6 Arrrggghhh! IE6 redenders the width of the main content column  smaller than Firefox and IE7, this causes the main content to be displayed below the content in the right sidebar, not good.</p>
<p>I think the fix is going to be fairly easy, I'll upload it here when I get it sorted.</p>
<p>I also installed the <a target="_blank" href="http://www.jonabad.com/livecalendar/">live calendar plugin</a> on my <a href="http://blog.petegraham.co.uk">Peteamania blog</a>, unfortunatley I've noticed that this plugin doesn't work correctly in IE7 (the hyperlinks never load). I don't think I can be bothered to fix this bug, although its a nifty little AJAX plugin it doesn't offer much improved functionality over the bog standard wordpress calendar.</p>
<p># Pete Graham</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.petegraham.co.uk/2007/01/27/curse-you-internet-explorer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

