<?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>A Web Developers Blog &#187; Javascript</title>
	<atom:link href="http://jamesowers.co.uk/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://jamesowers.co.uk</link>
	<description>The blog of James Owers, a Newcastle based web developer.</description>
	<lastBuildDate>Sun, 22 Apr 2012 20:27:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>jQuery Tagging Plugins</title>
		<link>http://jamesowers.co.uk/javascript/633/jquery-tagging-plugins/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jquery-tagging-plugins</link>
		<comments>http://jamesowers.co.uk/javascript/633/jquery-tagging-plugins/#comments</comments>
		<pubDate>Thu, 22 Mar 2012 14:16:29 +0000</pubDate>
		<dc:creator>jmz</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://jamesowers.co.uk/?p=633</guid>
		<description><![CDATA[If you have an application where people add a lot of data, organising this data to make it easy for people to find what they want can be difficult. One simple solution that can make organising and finding this data simple is to allow your users to add tags to each item. I was looking [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-694" title="tag_img" src="http://jamesowers.co.uk/wp-content/uploads/tag_img.jpg" alt="" width="496" height="85" /></p>
<p>If you have an application where people add a lot of data, organising this data to make it easy for people to find what they want can be difficult. One simple solution that can make organising and finding this data simple is to allow your users to add tags to each item.</p>
<p>I was looking for a good jQuery plugin for an app I&#8217;ve been working on and I thought it might be useful to some people if I did a quick round up of the ones I had a look at.<br />
<span id="more-633"></span></p>
<h2>JQUERY TAGS INPUT PLUGIN</h2>
<p><a href="http://xoxco.com/projects/code/tagsinput/"><img class="alignnone size-full wp-image-635" title="JQUERY TAGS INPUT PLUGIN" src="http://jamesowers.co.uk/wp-content/uploads/xoxco.jpg" alt="" width="300" height="158" /></a></p>
<h2>Tagit</h2>
<p><a href="http://webspirited.com/tagit/"><img class="alignnone size-full wp-image-637" title="Tagit" src="http://jamesowers.co.uk/wp-content/uploads/tagit.jpg" alt="" width="290" height="47" /></a></p>
<h2>jQuery Tag Plugin</h2>
<p><a href="http://www.fatihkadirakin.com/dev/jquerytag/"><img class="alignnone size-full wp-image-638" title="jQuery Tag Plugin" src="http://jamesowers.co.uk/wp-content/uploads/tagplugin.jpg" alt="" width="294" height="54" /></a></p>
<h2>Tagzy</h2>
<p>In the end, Tagzy was the plugin I decided to use for the tags in my application. I thought it was nice and simple to implement and use.</p>
<p><a href="http://theodin.co.uk/blog/jquery/tagzy-tagging-jquery-plugin.html"><img class="alignnone size-full wp-image-639" title="Tagzy jQuery tag plugin" src="http://jamesowers.co.uk/wp-content/uploads/tagzy.jpg" alt="" width="395" height="267" /></a></p>
<p>Also, here is a little screenshot of it in action in my app. Changing the look of the tags was really straight forward too!</p>
<p><img class="alignnone size-full wp-image-641" title="tagzy2" src="http://jamesowers.co.uk/wp-content/uploads/tagzy2.jpg" alt="" width="395" height="161" /></p>
]]></content:encoded>
			<wfw:commentRss>http://jamesowers.co.uk/javascript/633/jquery-tagging-plugins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easily get javascript libraries using Script SRC</title>
		<link>http://jamesowers.co.uk/general/526/script-src/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=script-src</link>
		<comments>http://jamesowers.co.uk/general/526/script-src/#comments</comments>
		<pubDate>Tue, 25 May 2010 09:17:40 +0000</pubDate>
		<dc:creator>jmz</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://jamesowers.co.uk/?p=526</guid>
		<description><![CDATA[When developing a new site I always like to make sure I use the latest release of my javascript library hosted by Google. Then I just update it to a local version before the site goes live. Today I came across a great little site that lets you get the links to the latest versions [...]]]></description>
			<content:encoded><![CDATA[<p>When developing a new site I always like to make sure I use the latest release of my javascript library hosted by Google. Then I just update it to a local version before the site goes live.</p>
<p>Today I came across a great little site that lets you get the links to the latest versions of the most popular javascript libraries quickly and easily.</p>
<p><span id="more-526"></span></p>
<p><a href="http://scriptsrc.net/"><img src="http://jamesowers.co.uk/wp-content/uploads/scriptsrc.png" alt="scriptsrc" title="scriptsrc" width="520" height="129" class="alignnone size-full wp-image-527" /></a></p>
<p>You find your library on the page and click the &#8216;Copy&#8217; button. Then all the code you need to include the library in your page is copied to your clipboard. </p>
<p>I really like simple, easy to use sites like this that do one thing and do it well rather than trying to do too much.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesowers.co.uk/general/526/script-src/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Enabling and disabling a text input with a checkbox using jQuery</title>
		<link>http://jamesowers.co.uk/javascript/506/enabling-and-disabling-a-text-input-with-a-checkbox-using-jquery/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=enabling-and-disabling-a-text-input-with-a-checkbox-using-jquery</link>
		<comments>http://jamesowers.co.uk/javascript/506/enabling-and-disabling-a-text-input-with-a-checkbox-using-jquery/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 07:00:22 +0000</pubDate>
		<dc:creator>jmz</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://jamesowers.co.uk/?p=506</guid>
		<description><![CDATA[I wanted to make a quick bit of javascript that would enable or disable a text input based on whether a checkbox was checked or not. I thought this might come in handy so I made it into a tutorial and posted it here. This script will work for any amount of checkboxes and text [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.jamesowers.co.uk/wp-content/uploads/roi/input_img.gif" alt="Enabling and disabling a text input with a checkbox using jQuery" /></p>
<p>I wanted to make a quick bit of javascript that would enable or disable a text input based on whether a checkbox was checked or not. I thought this might come in handy so I made it into a tutorial and posted it here. This script will work for any amount of checkboxes and text inputs on a page. You can see a <a href="http://jamesowers.co.uk/wp-content/uploads/roi/demo.html">working demo of it here</a>.</p>
<p><span id="more-506"></span></p>
<p>First we start off with our blank HTML page.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;Enabling and disabling a text input with a checkbox using jQuery&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Next include the jQuery js file from Google.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;Readonly Input Box&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Next we add our text inputs and check boxes. I have also added some labels so that you can see which check box goes with which input. I have added 3 inputs so to show that you can use this technique with multiple boxes.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;Readonly Input Box&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Readonly Input Box&lt;/h1&gt;

&lt;label&gt;My Test Label 1&lt;/label&gt;
&lt;input type=&quot;checkbox&quot;/&gt;
&lt;input type=&quot;text&quot; name=&quot;test1&quot; /&gt;

&lt;br /&gt;

&lt;label&gt;My Test Label 2&lt;/label&gt;
&lt;input type=&quot;checkbox&quot;/&gt;
&lt;input type=&quot;text&quot; name=&quot;test2&quot; /&gt;

&lt;br /&gt;

&lt;label&gt;My Test Label 3&lt;/label&gt;
&lt;input type=&quot;checkbox&quot;/&gt;
&lt;input type=&quot;text&quot; name=&quot;test3&quot; /&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Now I add a class to each check box so that I know which check boxes I want jQuery to watch for clicks on. You don&#8217;t have to do this but you might get some strange results if you didn&#8217;t and you had other check boxes on your page.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;Readonly Input Box&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Readonly Input Box&lt;/h1&gt;

&lt;label&gt;My Test Label 1&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; class=&quot;input_control&quot;/&gt;
&lt;input type=&quot;text&quot; name=&quot;test1&quot; /&gt;

&lt;br /&gt;

&lt;label&gt;My Test Label 2&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; class=&quot;input_control&quot;/&gt;
&lt;input type=&quot;text&quot; name=&quot;test2&quot; /&gt;

&lt;br /&gt;

&lt;label&gt;My Test Label 3&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; class=&quot;input_control&quot;/&gt;
&lt;input type=&quot;text&quot; name=&quot;test3&quot; /&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>I&#8217;ll also add a value to each check box, this will match the name of the input I want it to control.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;Readonly Input Box&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Readonly Input Box&lt;/h1&gt;

&lt;label&gt;My Test Label 1&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; class=&quot;input_control&quot; value=&quot;test1&quot;/&gt;
&lt;input type=&quot;text&quot; name=&quot;test1&quot; /&gt;

&lt;br /&gt;

&lt;label&gt;My Test Label 2&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; class=&quot;input_control&quot; value=&quot;test2&quot;/&gt;
&lt;input type=&quot;text&quot; name=&quot;test2&quot; /&gt;

&lt;br /&gt;

&lt;label&gt;My Test Label 3&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; class=&quot;input_control&quot; value=&quot;test3&quot;/&gt;
&lt;input type=&quot;text&quot; name=&quot;test3&quot; /&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Next, the jQuery. First of all we need the javascript tags, this normally goes at the end of the document so that the HTML &#038; CSS are loaded before any javascript, giving the user the impression that the page is loading faster.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;Readonly Input Box&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;h1&gt;Readonly Input Box&lt;/h1&gt;

&lt;label&gt;My Test Label 1&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; class=&quot;input_control&quot; value=&quot;test1&quot;/&gt;
&lt;input type=&quot;text&quot; name=&quot;test1&quot; /&gt;

&lt;br /&gt;

&lt;label&gt;My Test Label 2&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; class=&quot;input_control&quot; value=&quot;test2&quot;/&gt;
&lt;input type=&quot;text&quot; name=&quot;test2&quot; /&gt;

&lt;br /&gt;

&lt;label&gt;My Test Label 3&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; class=&quot;input_control&quot; value=&quot;test3&quot;/&gt;
&lt;input type=&quot;text&quot; name=&quot;test3&quot; /&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
	$(document).ready(function(){
//Our code will go in here
	});
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>This tutorial will only deal with inputs that are all enabled when the page first loads (I might write another one in the future that covers having some disabled when the page loads) so we need to make sure that all the checkboxes are checked when the page loads. I did this with javascript, this might not be the right way to do it if you want it to degrade gracefully. To check all of my checkboxes when the page loads I use the code.</p>
<pre class="brush: jscript; title: ; notranslate">
	$(document).ready(function(){
		$('.input_control').attr('checked', true);
	});
</pre>
<p>Next I write some jQuery code that tells jQuery to do something whenever someone clicks one of the checkboxes with the class of &#8216;input_control&#8217;.</p>
<pre class="brush: jscript; title: ; notranslate">
	$(document).ready(function(){
		$('.input_control').attr('checked', true);
		$('.input_control').click(function(){
//Do this when someone clicks something with the class input_control
		});
	});
</pre>
<p>Now we do a simple if statement that says &#8216;if the check box was checked then set the disabled attribute to false, if the check box was unchecked then set the disabled attribute to true.</p>
<pre class="brush: jscript; title: ; notranslate">
	$(document).ready(function(){
		$('.input_control').attr('checked', true);
		$('.input_control').click(function(){
			if($('input[name='+ $(this).attr('value')+']').attr('disabled') == false){
				$('input[name='+ $(this).attr('value')+']').attr('disabled', true);
			}else{
				$('input[name='+ $(this).attr('value')+']').attr('disabled', false);
			}
		});
	});
</pre>
<p>And that&#8217;s it! I&#8217;ve added the code of the completed page below and you can <a href="http://jamesowers.co.uk/wp-content/uploads/roi/demo.html">see a demo here</a>. There are probably other ways of doing this, but this is the simplest way that I came up with. I did try doing this with toggle rather than using an if statement but although the disable/enable checkbox worked, the checkbox didn&#8217;t check/uncheck.</p>
<h2>Completed Page</h2>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;Readonly Input Box&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;h1&gt;Readonly Input Box&lt;/h1&gt;

&lt;label&gt;My Test Label 1&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; class=&quot;input_control&quot; value=&quot;test1&quot;/&gt;
&lt;input type=&quot;text&quot; name=&quot;test1&quot; /&gt;

&lt;br /&gt;

&lt;label&gt;My Test Label 2&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; class=&quot;input_control&quot; value=&quot;test2&quot;/&gt;
&lt;input type=&quot;text&quot; name=&quot;test2&quot; /&gt;

&lt;br /&gt;

&lt;label&gt;My Test Label 3&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; class=&quot;input_control&quot; value=&quot;test3&quot;/&gt;
&lt;input type=&quot;text&quot; name=&quot;test3&quot; /&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
	$(document).ready(function(){
		$('.input_control').attr('checked', true);
		$('.input_control').click(function(){
			if($('input[name='+ $(this).attr('value')+']').attr('disabled') == false){
				$('input[name='+ $(this).attr('value')+']').attr('disabled', true);
			}else{
				$('input[name='+ $(this).attr('value')+']').attr('disabled', false);
			}
		});
	});
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jamesowers.co.uk/javascript/506/enabling-and-disabling-a-text-input-with-a-checkbox-using-jquery/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Javascript Confirm Box</title>
		<link>http://jamesowers.co.uk/javascript/303/javascript-confirm-box/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=javascript-confirm-box</link>
		<comments>http://jamesowers.co.uk/javascript/303/javascript-confirm-box/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 07:00:30 +0000</pubDate>
		<dc:creator>jmz</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://jamesowers.co.uk/?p=303</guid>
		<description><![CDATA[A lot of developers have found that users can sometimes click links without thinking, this is not normally too harmful unless the button does something like delete a record from a database. That is why a lot of sites use confirmation boxes that will ask a user &#8220;Do you really want to delete this?&#8221; before [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of developers have found that users can sometimes click links without thinking, this is not normally too harmful unless the button does something like delete a record from a database. That is why a lot of sites use confirmation boxes that will ask a user &#8220;Do you really want to delete this?&#8221; before the action is completed.</p>
<p>This tutorial will show you how to create a javascript function that will allow you to do this really easily.</p>
<p><strong>Here&#8217;s an example of what we will be creating:</strong><br />
<img src="http://www.jamesowers.co.uk/wp-content/uploads/js_demo.gif" alt="Javascript confirm box" /></p>
<p><span id="more-303"></span></p>
<div class="demo-link"><a href="http://www.jamesowers.co.uk/wp-content/uploads/js_confirm/index.html" title="Javascript confirm box">View A Demo</a></div>
<p>First of all we will need our link that will delete the record, I&#8217;ll just use a dummy page with the link on like this:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.1//EN&quot; &quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&quot;&gt;
&lt;html&gt;
	&lt;head&gt;
    		&lt;title&gt;Javascript Confirm Example&lt;/title&gt;
		&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot; /&gt;
	&lt;/head&gt;
	&lt;body&gt;
		&lt;a href=&quot;delete.html&quot;&gt;Delete&lt;/a&gt;
	&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>The &#8220;Delete&#8221; link is going to be the link we&#8217;ll add the confirmation to.</p>
<p>Next we need our javascript function:</p>
<pre class="brush: jscript; title: ; notranslate">
function confirmDelete(delUrl) {
  if (confirm(&quot;Are you sure?&quot;)) {
    document.location = delUrl;
  }
}
</pre>
<p>The javascript is pretty simple. When the user clicks the link, a confirm box is popped up. The text from the confirm box is the &#8220;Are you sure?&#8221; text. If the user clicks &#8220;Ok&#8221; then they are redirected to the delUrl link, otherwise they stay on the page they are on.</p>
<p>Now we need to make a few changes to the HTML. We need to add the javascript function and we need to tell the link to run the function when it is clicked.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.1//EN&quot; &quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&quot;&gt;
&lt;html&gt;
	&lt;head&gt;
    		&lt;title&gt;Javascript Confirm Example&lt;/title&gt;
		&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot; /&gt;
		&lt;script type=&quot;text/javascript&quot;&gt;
			function confirmDelete(delUrl) {
				if (confirm(&quot;Are you sure?&quot;)) {
					document.location = delUrl;
				}
			}
		&lt;/script&gt;
	&lt;/head&gt;
	&lt;body&gt;
		&lt;a href=&quot;javascript:confirmDelete('delete.html')&quot;&gt;Delete&lt;/a&gt;
	&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Now you can see in the example, when the link is clicked a box pops up and asks you if you are sure, if you click Ok you go to the delete.html page, if you click Cancel you go back to the page you were on. Simple!</p>
<p>Now, lets make this function a little bit more generic. Say we had one link on our site to delete the item, like in the example above. But we also had a link to let a user hide an item aswell. Using the code above, we would need one function to say &#8220;Are you sure you want to delete this item?&#8221; and one to say &#8220;Are you sure you want to hide this item?&#8221; which we really don&#8217;t want to do if we can get away with it.</p>
<p>So if you need to, you can use this slightly modified function.</p>
<pre class="brush: jscript; title: ; notranslate">
		&lt;script type=&quot;text/javascript&quot;&gt;
			function confirmDelete(delUrl,msg) {
				if (confirm(msg)) {
					document.location = delUrl;
				}
			}
		&lt;/script&gt;
</pre>
<p>Basically, all we&#8217;ve done here is, rather than hard coding the text that is displayed in the confirm box, we&#8217;ve set it as a variable called msg which is passed from the link.</p>
<p>The code for our page now looks like this.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.1//EN&quot; &quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&quot;&gt;
&lt;html&gt;
	&lt;head&gt;
    		&lt;title&gt;Javascript Confirm Example&lt;/title&gt;
		&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot; /&gt;
		&lt;script type=&quot;text/javascript&quot;&gt;
			function confirmDelete(delUrl,msg) {
				if (confirm(msg)) {
					document.location = delUrl;
				}
			}
		&lt;/script&gt;
	&lt;/head&gt;
	&lt;body&gt;
		&lt;a href=&quot;javascript:confirmDelete('delete.html','Delete this?')&quot;&gt;Delete&lt;/a&gt; | &lt;a href=&quot;javascript:confirmDelete('hide.html','Hide this?')&quot;&gt;Hide&lt;/a&gt;
	&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>You might have noticed I&#8217;ve changed the links slightly to include the text to go in the confirm box. </p>
<div class="demo-link"><a href="http://www.jamesowers.co.uk/wp-content/uploads/js_confirm/index.html" title="Javascript confirm box">View A Demo</a></div>
<p>And that&#8217;s it, you now have a delete confirmation function that can link to any page and display any message.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesowers.co.uk/javascript/303/javascript-confirm-box/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free WYSIWYG editors</title>
		<link>http://jamesowers.co.uk/javascript/201/free-wysiwyg-editors/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=free-wysiwyg-editors</link>
		<comments>http://jamesowers.co.uk/javascript/201/free-wysiwyg-editors/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 11:03:44 +0000</pubDate>
		<dc:creator>jmz</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://jamesowers.co.uk/?p=201</guid>
		<description><![CDATA[As a developer, there will inevitably be a time when you have to use a WYSIWYG editor in one of your projects. There are a huge range of these editors that all have good and bad bits and that all have different price ranges. In this roundup, I&#8217;ve decided to only include the ones that [...]]]></description>
			<content:encoded><![CDATA[<p>As a developer, there will inevitably be a time when you have to use a WYSIWYG editor in one of your projects. There are a huge range of these editors that all have good and bad bits and that all have different price ranges. In this roundup, I&#8217;ve decided to only include the ones that cost my favourite price,<strong> FREE!!</strong></p>
<p><span id="more-201"></span></p>
<h2><a href="http://tinymce.moxiecode.com/">TinyMCE</a></h2>
<p><a href="http://jamesowers.co.uk/wp-content/uploads/2009/03/mce.jpg"><br />
<img src="http://jamesowers.co.uk/wp-content/uploads/2009/03/mce.jpg" alt="mce" title="mce" style="width:95%" class="alignnone size-full wp-image-204" /><br />
</a><br />
<br style="clear:both"/></p>
<h2><a href="http://www.fckeditor.net/">FCKEditor</a></h2>
<p><a href="http://jamesowers.co.uk/wp-content/uploads/2009/03/fck.jpg"><br />
<img src="http://jamesowers.co.uk/wp-content/uploads/2009/03/fck.jpg" alt="fck" title="fck" style="width:95%" class="alignnone size-full wp-image-205" /><br />
</a><br />
<br style="clear:both"/></p>
<h2><a href="http://projects.bundleweb.com.ar/jWYSIWYG/">jwysiwyg</a></h2>
<p><a href="http://jamesowers.co.uk/wp-content/uploads/2009/03/fck.jpg"><br />
<img src="http://jamesowers.co.uk/wp-content/uploads/2009/03/jwy.jpg" alt="jwy" title="jwy" style="width:95%" class="alignnone size-full wp-image-206" /><br />
</a><br />
<br style="clear:both"/></p>
<h2><a href="http://www.openwebware.com/">openWYSIWYG</a></h2>
<p><a href="http://jamesowers.co.uk/wp-content/uploads/2009/03/fck.jpg"><br />
<img src="http://jamesowers.co.uk/wp-content/uploads/2009/03/owy.jpg" alt="owy" title="owy" style="width:95%" class="alignnone size-full wp-image-207" /><br />
</a><br />
<br style="clear:both"/></p>
<h2><a href="http://www.ewelive.com/">EWELive</a></h2>
<p><a href="http://jamesowers.co.uk/wp-content/uploads/2009/03/fck.jpg"><br />
<img src="http://jamesowers.co.uk/wp-content/uploads/2009/03/ewe.jpg" alt="ewe" title="ewe" style="width:95%" class="alignnone size-full wp-image-208" /><br />
</a><br />
<br style="clear:both"/></p>
<h2><a href="http://freerichtexteditor.com/">Free Rich Text Editor</a></h2>
<p><a href="http://jamesowers.co.uk/wp-content/uploads/2009/03/fck.jpg"><br />
<img src="http://jamesowers.co.uk/wp-content/uploads/2009/03/freertf.jpg" alt="freertf" title="freertf" style="width:95%" class="alignnone size-full wp-image-209" /><br />
</a><br />
<br style="clear:both"/></p>
<p>If you know of another WYSIWYG editors that should be listed here, leave a comment and I&#8217;ll get it up!</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesowers.co.uk/javascript/201/free-wysiwyg-editors/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

