<?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>Website Design Peterborough, Jigowatt - Magento Web Design, UK &#187; CodeCanyon</title>
	<atom:link href="http://www.jigowatt.co.uk/category/blog/codecanyon/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jigowatt.co.uk</link>
	<description>Website Design Peterborough</description>
	<lastBuildDate>Wed, 25 Aug 2010 09:13:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>AJAX Contact Form; Add / Validate Checkboxes</title>
		<link>http://www.jigowatt.co.uk/blog/general/ajax-contact-form-add-checkboxes</link>
		<comments>http://www.jigowatt.co.uk/blog/general/ajax-contact-form-add-checkboxes#comments</comments>
		<pubDate>Wed, 17 Feb 2010 23:12:08 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[CodeCanyon]]></category>
		<category><![CDATA[Envato]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://jigowatt.co.uk/?p=857</guid>
		<description><![CDATA[For all our AJAX Contact Form customers on CodeCanyon, here&#8217;s a quick tutorial on how to add / validate checkboxes. As some have found, the standard Javascript .val() request does not work with checkboxes, for ...


Related posts:<ol><li><a href='http://www.jigowatt.co.uk/blog/ajax-contact-form-add-or-remove-custom-fields' rel='bookmark' title='Permanent Link: AJAX Contact Form; Add or Remove Custom Fields'>AJAX Contact Form; Add or Remove Custom Fields</a></li>
<li><a href='http://www.jigowatt.co.uk/blog/shopp-tutorial-only-display-top-level-categories' rel='bookmark' title='Permanent Link: Shopp tutorial; only display top level categories'>Shopp tutorial; only display top level categories</a></li>
<li><a href='http://www.jigowatt.co.uk/blog/change-the-first-day-on-our-php-event-calendar-script' rel='bookmark' title='Permanent Link: Change the first day on our PHP Event Calendar Script'>Change the first day on our PHP Event Calendar Script</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>For all our <a href="http://codecanyon.net/item/ajax-contact-form/50846?ref=jigowatt" alt="Jigowatt AJAX Contact Form" />AJAX Contact Form</a> customers on <a href="http://codecanyon.net/user/jigowatt?ref=jigowatt" alt="CodeCanyon Jigowatt" />CodeCanyon</a>, here&#8217;s a quick tutorial on how to add / validate checkboxes.</p>
<p>As some have found, the standard Javascript .val() request does not work with checkboxes, for this reason we&#8217;ll need to add a quick function to our Javascript handling file, here&#8217;s one we made earlier&#8230; add this at line 14 of jquery.jigowatt.js</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">function</span> getCheckedValue<span style="color: #009900;">&#40;</span>field<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; field <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#'</span> <span style="color: #339933;">+</span> field<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; txt <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> field.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>field<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">checked</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> txt <span style="color: #339933;">=</span> field<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span> <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>txt <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;0&quot;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;1&quot;</span> <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Using this function will return a &#8217;1&#8242; value if the checkbox is ticked and a &#8217;0&#8242; if it isn&#8217;t, this will make it very easy for you to validate in the contact.php file.</p>
<p>Note: If for any reason you need the checkbox&#8217;s value returned for validation you need to replace</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>txt <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;0&quot;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;1&quot;</span> <span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>with..</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>txt <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;0&quot;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> txt <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; &quot;</span> <span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Now you just need to add the value to the post as normal.. aprox line 30 with the above function inserted</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">checkbox<span style="color: #339933;">:</span> &nbsp;getCheckedValue<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'checkbox'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></div></td></tr></tbody></table></div>
<p>For your reference, our HTML for the Checkbox looks like this..</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/br.html"><span style="color: #000000; font-weight: bold;">br</span></a> <span style="color: #66cc66;">/</span>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Milk&quot;</span>&gt;</span> Milk<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/br.html"><span style="color: #000000; font-weight: bold;">br</span></a> <span style="color: #66cc66;">/</span>&gt;</span></div></td></tr></tbody></table></div>
<p>And that&#8217;s it on our part, now with some validation you&#8217;ll be well on your way to passing checkbox variables.</p>


<p>Related posts:<ol><li><a href='http://www.jigowatt.co.uk/blog/ajax-contact-form-add-or-remove-custom-fields' rel='bookmark' title='Permanent Link: AJAX Contact Form; Add or Remove Custom Fields'>AJAX Contact Form; Add or Remove Custom Fields</a></li>
<li><a href='http://www.jigowatt.co.uk/blog/shopp-tutorial-only-display-top-level-categories' rel='bookmark' title='Permanent Link: Shopp tutorial; only display top level categories'>Shopp tutorial; only display top level categories</a></li>
<li><a href='http://www.jigowatt.co.uk/blog/change-the-first-day-on-our-php-event-calendar-script' rel='bookmark' title='Permanent Link: Change the first day on our PHP Event Calendar Script'>Change the first day on our PHP Event Calendar Script</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jigowatt.co.uk/blog/general/ajax-contact-form-add-checkboxes/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
