<?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>Ruben Sargsyan &#187; check/uncheck</title>
	<atom:link href="http://rubensargsyan.com/tag/checkuncheck/feed/" rel="self" type="application/rss+xml" />
	<link>http://rubensargsyan.com</link>
	<description>Personal Website</description>
	<lastBuildDate>Fri, 27 Aug 2010 07:08:55 +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>Check/uncheck checkboxes by JavaScript</title>
		<link>http://rubensargsyan.com/checkuncheck-checkboxes-by-javascript/</link>
		<comments>http://rubensargsyan.com/checkuncheck-checkboxes-by-javascript/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 13:34:40 +0000</pubDate>
		<dc:creator>Ruben Sargsyan</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[check/uncheck]]></category>
		<category><![CDATA[checkboxes]]></category>

		<guid isPermaLink="false">http://rubensargsyan.com/?p=149</guid>
		<description><![CDATA[The easy way to check/uncheck checkboxes. Insert into &#60;head&#62;&#60;/head&#62; this script &#60;script type=&#34;text/javascript&#34;&#62; function check_all&#40;&#41;&#123; var all_inputs = document.getElementsByTagName&#40;&#34;input&#34;&#41;; &#160; for&#40;i=0; i&#60;all_inputs.length; i++&#41;&#123; if&#40;all_inputs&#91;i&#93;.type==&#34;checkbox&#34; &#38;&#38; all_inputs&#91;i&#93;.className==&#34;check_uncheck&#34;&#41;&#123; all_inputs&#91;i&#93;.checked = &#34;checked&#34;; &#125; &#125; &#125; &#160; function uncheck_all&#40;&#41;&#123; var all_inputs = document.getElementsByTagName&#40;&#34;input&#34;&#41;; &#160; for&#40;i=0; i&#60;all_inputs.length; i++&#41;&#123; if&#40;all_inputs&#91;i&#93;.type==&#34;checkbox&#34; &#38;&#38; all_inputs&#91;i&#93;.className==&#34;check_uncheck&#34;&#41;&#123; all_inputs&#91;i&#93;.checked = &#34;&#34;; &#125; &#125; &#125; &#60;/script&#62; then set [...]]]></description>
			<content:encoded><![CDATA[<p>The easy way to check/uncheck checkboxes. Insert into &lt;head&gt;&lt;/head&gt; this script<span id="more-149"></span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
function check_all<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   var all_inputs <span style="color: #339933;">=</span> document.<span style="color: #006633;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;input&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>all_inputs.<span style="color: #006633;">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>
      <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>all_inputs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">type</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;checkbox&quot;</span> <span style="color: #339933;">&amp;&amp;</span> all_inputs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">className</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;check_uncheck&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         all_inputs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">checked</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;checked&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
function uncheck_all<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   var all_inputs <span style="color: #339933;">=</span> document.<span style="color: #006633;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;input&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>all_inputs.<span style="color: #006633;">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>
      <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>all_inputs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">type</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;checkbox&quot;</span> <span style="color: #339933;">&amp;&amp;</span> all_inputs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">className</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;check_uncheck&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         all_inputs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">checked</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>then set &#8220;check_uncheck&#8221; the classes of checkboxes which must check/uncheck (Example: <span style="color: #993300;">&lt;input type=&#8221;checkbox&#8221; name=&#8221;checkbox&#8221;&gt;</span>) and set onclick=&#8221;check_all()&#8221; to element on click which the checkboxes will be checked and onclick=&#8221;uncheck_all()&#8221; to element on click which the checkboxes will be unchecked (Example: <span style="color: #993300;">&lt;input type=&#8221;button&#8221; value=&#8221;Check&#8221; onclick=&#8221;check_all()&#8221;&gt; &lt;input type=&#8221;button&#8221; value=&#8221;Uncheck&#8221; onclick=&#8221;uncheck_all()&#8221;&gt;</span>).</p>
]]></content:encoded>
			<wfw:commentRss>http://rubensargsyan.com/checkuncheck-checkboxes-by-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
