<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Unchecked checkbox values</title>
	<atom:link href="http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/feed/" rel="self" type="application/rss+xml" />
	<link>http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/</link>
	<description>Cameron Perry's web development blog</description>
	<lastBuildDate>Thu, 22 Oct 2009 21:20:01 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: dmitry</title>
		<link>http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6682</link>
		<dc:creator>dmitry</dc:creator>
		<pubDate>Mon, 14 Sep 2009 05:53:09 +0000</pubDate>
		<guid isPermaLink="false">http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6682</guid>
		<description>Solved my problem.  Thanks</description>
		<content:encoded><![CDATA[<p>Solved my problem.  Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul d'Aoust</title>
		<link>http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6679</link>
		<dc:creator>Paul d'Aoust</dc:creator>
		<pubDate>Thu, 06 Aug 2009 21:55:17 +0000</pubDate>
		<guid isPermaLink="false">http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6679</guid>
		<description>Brilliant! I never would&#039;ve thought of this. Thanks for the tip!</description>
		<content:encoded><![CDATA[<p>Brilliant! I never would&#8217;ve thought of this. Thanks for the tip!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cameron Perry</title>
		<link>http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6678</link>
		<dc:creator>Cameron Perry</dc:creator>
		<pubDate>Fri, 24 Jul 2009 22:23:07 +0000</pubDate>
		<guid isPermaLink="false">http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6678</guid>
		<description>I&#039;m glad it worked out for you. And I agree - arrays aren&#039;t necessary - they&#039;re more work than they are worth for such a simple problem.</description>
		<content:encoded><![CDATA[<p>I&#8217;m glad it worked out for you. And I agree &#8211; arrays aren&#8217;t necessary &#8211; they&#8217;re more work than they are worth for such a simple problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Theresa</title>
		<link>http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6677</link>
		<dc:creator>Theresa</dc:creator>
		<pubDate>Fri, 24 Jul 2009 13:31:43 +0000</pubDate>
		<guid isPermaLink="false">http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6677</guid>
		<description>The original hidden works perfectly without any need for arrays. BEAUTIFUL! wahhoo, been tryin to figure this out all week.</description>
		<content:encoded><![CDATA[<p>The original hidden works perfectly without any need for arrays. BEAUTIFUL! wahhoo, been tryin to figure this out all week.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6665</link>
		<dc:creator>James</dc:creator>
		<pubDate>Tue, 12 May 2009 11:43:22 +0000</pubDate>
		<guid isPermaLink="false">http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6665</guid>
		<description>nice trick.
saves a lot of hard work.
thanks</description>
		<content:encoded><![CDATA[<p>nice trick.<br />
saves a lot of hard work.<br />
thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: charliesvensson</title>
		<link>http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6664</link>
		<dc:creator>charliesvensson</dc:creator>
		<pubDate>Tue, 12 May 2009 10:45:10 +0000</pubDate>
		<guid isPermaLink="false">http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6664</guid>
		<description>Fuckin hell! :D

Ive been going crazy about this shit for a couple of months now! AND FINALLY SOME ONE DOES THE TRICK! :D

Cant thank you enough!</description>
		<content:encoded><![CDATA[<p>Fuckin hell! :D</p>
<p>Ive been going crazy about this shit for a couple of months now! AND FINALLY SOME ONE DOES THE TRICK! :D</p>
<p>Cant thank you enough!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cameron Perry</title>
		<link>http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6663</link>
		<dc:creator>Cameron Perry</dc:creator>
		<pubDate>Fri, 08 May 2009 20:42:38 +0000</pubDate>
		<guid isPermaLink="false">http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6663</guid>
		<description>Shony,

You can definitely do it that way, but it gets tedious if you have a lot of checkboxes - to have to pay attention to it in both your HTML and the PHP code. Consider the situation where you&#039;re matching submitted form data against database field - only the matching set gets saved, you either have to manually write-in checks for every single checkbox field (a pain and error-prone if you forget one), or you can do something like this and not have to worry about it.</description>
		<content:encoded><![CDATA[<p>Shony,</p>
<p>You can definitely do it that way, but it gets tedious if you have a lot of checkboxes &#8211; to have to pay attention to it in both your HTML and the PHP code. Consider the situation where you&#8217;re matching submitted form data against database field &#8211; only the matching set gets saved, you either have to manually write-in checks for every single checkbox field (a pain and error-prone if you forget one), or you can do something like this and not have to worry about it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shony</title>
		<link>http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6662</link>
		<dc:creator>Shony</dc:creator>
		<pubDate>Fri, 08 May 2009 20:35:03 +0000</pubDate>
		<guid isPermaLink="false">http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6662</guid>
		<description>Cameron, I love your thinking with this idea.
is there any reason why we cannot do on the back end in PHP

if ( empty($_POST[&#039;box1&#039;]) ) { 
  $my_value = 0;
} else {
  $my_value = $_POST[&#039;box1&#039;];
}

Or we can also evaluate for isset instead of empty().

And with this we may not even need the hidden input helper there on the form.

No?</description>
		<content:encoded><![CDATA[<p>Cameron, I love your thinking with this idea.<br />
is there any reason why we cannot do on the back end in PHP</p>
<p>if ( empty($_POST['box1']) ) {<br />
  $my_value = 0;<br />
} else {<br />
  $my_value = $_POST['box1'];<br />
}</p>
<p>Or we can also evaluate for isset instead of empty().</p>
<p>And with this we may not even need the hidden input helper there on the form.</p>
<p>No?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JC</title>
		<link>http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6655</link>
		<dc:creator>JC</dc:creator>
		<pubDate>Wed, 25 Mar 2009 05:54:23 +0000</pubDate>
		<guid isPermaLink="false">http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6655</guid>
		<description>In JSP if you are using a bean (either via JSP tags or something else like Apache BeanUtils), you can use logic like this to make this work:

class MyBean {
  ...
  Boolean checkval;
  ...
  public void setCheckval (boolean b) {
    if (checkval == null)
      checkval = b;
    else
      checkval = checkval &#124; b;
  }
  ...
}

That will OR all of the &quot;checkval&quot; parameters together, but still leave MyBean.checkval as null if none were specified. If you aren&#039;t using a bean, you can still apply similar logic when going through the request parameter map (go through the entire array of &quot;checkval&quot; values and do the same thing).</description>
		<content:encoded><![CDATA[<p>In JSP if you are using a bean (either via JSP tags or something else like Apache BeanUtils), you can use logic like this to make this work:</p>
<p>class MyBean {<br />
  &#8230;<br />
  Boolean checkval;<br />
  &#8230;<br />
  public void setCheckval (boolean b) {<br />
    if (checkval == null)<br />
      checkval = b;<br />
    else<br />
      checkval = checkval | b;<br />
  }<br />
  &#8230;<br />
}</p>
<p>That will OR all of the &#8220;checkval&#8221; parameters together, but still leave MyBean.checkval as null if none were specified. If you aren&#8217;t using a bean, you can still apply similar logic when going through the request parameter map (go through the entire array of &#8220;checkval&#8221; values and do the same thing).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cameron Perry</title>
		<link>http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6653</link>
		<dc:creator>Cameron Perry</dc:creator>
		<pubDate>Tue, 10 Mar 2009 00:00:08 +0000</pubDate>
		<guid isPermaLink="false">http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/#comment-6653</guid>
		<description>This solution is back-end agnostic, so it&#039;s up to the way your code handles POST data. I&#039;m not familiar with ASP, but I imagine the variables you actually have access to might be whatever is written to the POST string last. That&#039;s why the hidden input box works - the checkbox doesn&#039;t even get sent unless it&#039;s checked. If it was checked, the value would overwrite the value of the hidden input field. This all happens before your server gets a hold of the data. Make sense? You could also use JS to write a value to a hidden input field based on the value of the checkbox (checked/un-checked).</description>
		<content:encoded><![CDATA[<p>This solution is back-end agnostic, so it&#8217;s up to the way your code handles POST data. I&#8217;m not familiar with ASP, but I imagine the variables you actually have access to might be whatever is written to the POST string last. That&#8217;s why the hidden input box works &#8211; the checkbox doesn&#8217;t even get sent unless it&#8217;s checked. If it was checked, the value would overwrite the value of the hidden input field. This all happens before your server gets a hold of the data. Make sense? You could also use JS to write a value to a hidden input field based on the value of the checkbox (checked/un-checked).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
