<?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>swape.net &#187; form</title>
	<atom:link href="http://www.swape.net/w/tag/form/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.swape.net/w</link>
	<description>alireza balouch</description>
	<lastBuildDate>Wed, 21 Jul 2010 19:00:49 +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>Checkbox value</title>
		<link>http://www.swape.net/w/2008/04/checkbox-value/</link>
		<comments>http://www.swape.net/w/2008/04/checkbox-value/#comments</comments>
		<pubDate>Thu, 17 Apr 2008 12:06:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[When you post a form with checkbox it dose not return any value when the checkbox is not ticked. This is something that should have been fixed a long time ago. But for now here is the solution: &#60;form action=&#34;?&#34; method=&#34;post&#34;&#62; &#60;input name=&#34;myCheckbox&#34; type=&#34;hidden&#34; value=&#34;0&#34; /&#62; &#60;input name=&#34;myCheckbox&#34; type=&#34;checkbox&#34; /&#62; &#60;/form&#62; You put an hidden [...]]]></description>
			<content:encoded><![CDATA[<p>When you post a form with checkbox it dose not return any value when the checkbox is not ticked.<br />
This is something that should have been fixed a long time ago.<br />
But for now here is the solution:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="sc2"><a href="http://december.com/html/4/element/form.html"><span class="kw2">&lt;form</span></a> <span class="kw3">action</span>=<span class="st0">&quot;?&quot;</span> <span class="kw3">method</span>=<span class="st0">&quot;post&quot;</span><span class="kw2">&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"><a href="http://december.com/html/4/element/input.html"><span class="kw2">&lt;input</span></a> <span class="kw3">name</span>=<span class="st0">&quot;myCheckbox&quot;</span> <span class="kw3">type</span>=<span class="st0">&quot;hidden&quot;</span> <span class="kw3">value</span>=<span class="st0">&quot;0&quot;</span> /<span class="kw2">&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"><a href="http://december.com/html/4/element/input.html"><span class="kw2">&lt;input</span></a> <span class="kw3">name</span>=<span class="st0">&quot;myCheckbox&quot;</span> <span class="kw3">type</span>=<span class="st0">&quot;checkbox&quot;</span> /<span class="kw2">&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"><span class="kw2">&lt;/form&gt;</span></span></div>
</li>
</ol>
</div>
<p>You put an hidden input before checkbox input with the same name.<br />
Since the last checkbox overwrite the value when it is checked, the hidden input do not return "0" but when the checkbox is not checked, the hidden input with the same name returns a "0".</p>
<p>So when the checkbox is checked it returns "on" and when it is not checked it returns "0"</p>
<p>And to make it easier to click on the ckeckbox use "label" tag around the name.</p>
<p>Before:</p>
<div>
<input name="myCheckbox" type="checkbox" /> My Checkbox</div>
<p>After:</p>
<div><label><br />
<input name="myCheckbox" type="checkbox" />My Checkbox</label></div>
<p>This way you can click on the checkbox label and make it checked.<br />
The correct way to write an checkbox checked from the start is like this:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="sc2"><a href="http://december.com/html/4/element/label.html"><span class="kw2">&lt;label&gt;</span></a></span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"><a href="http://december.com/html/4/element/input.html"><span class="kw2">&lt;input</span></a> <span class="kw3">checked</span>=<span class="st0">&quot;checked&quot;</span> <span class="kw3">name</span>=<span class="st0">&quot;myCheckbox&quot;</span> <span class="kw3">type</span>=<span class="st0">&quot;checkbox&quot;</span> /<span class="kw2">&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1">My Checkbox</div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"><span class="kw2">&lt;/label&gt;</span></span></div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.swape.net/w/2008/04/checkbox-value/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
