<?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>Musings&#60;Biefeld&#62; &#187; Check Box</title>
	<atom:link href="http://sbiefeld.com/tag/check-box/feed/" rel="self" type="application/rss+xml" />
	<link>http://sbiefeld.com</link>
	<description>- curiosities of development, life, the universe and everything -</description>
	<lastBuildDate>Thu, 17 Nov 2011 04:01:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>JavaScript to Change CSS Class Based on Check Box State</title>
		<link>http://sbiefeld.com/2008/11/javascript-to-change-css-class-based-on-check-box-state/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=javascript-to-change-css-class-based-on-check-box-state</link>
		<comments>http://sbiefeld.com/2008/11/javascript-to-change-css-class-based-on-check-box-state/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 23:53:31 +0000</pubDate>
		<dc:creator>Sean Biefeld</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Check Box]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://sbiefeld.com/?p=16</guid>
		<description><![CDATA[Here is some useful JavaScript that wrote today to change a CSS class based on the state of a checkbox. function replaceCssClassOnElementBasedOnCheckBoxState(checkboxId, elementToChangeId, checkedCssClassName, uncheckedCssClassName) { var selectedElement = document.getElementById(elementToChangeId); var checkBox = document.getElementById(checkboxId); if(selectedElement &#38;&#38; checkBox) { if(checkBox.checked) selectedElement.className = checkedCssClassName; else selectedElement.className = uncheckedCssClassName; } } For Example: Check This! The style of [...]]]></description>
			<content:encoded><![CDATA[<p><script src="http://sbiefeld.com/scripts/examples.js" type="text/javascript"></script> Here is some useful JavaScript that wrote today to change a CSS class based on the state of a checkbox.</p>
<pre><span class="keyword">function</span> replaceCssClassOnElementBasedOnCheckBoxState(checkboxId, elementToChangeId, checkedCssClassName, uncheckedCssClassName)
{
    <span class="keyword">var</span> selectedElement = document.getElementById(elementToChangeId);
    <span class="keyword">var</span> checkBox = document.getElementById(checkboxId);
    <span class="keyword">if</span>(selectedElement &amp;&amp; checkBox)
    {
        <span class="keyword">if</span>(checkBox.<span class="keyword">checked</span>)
            selectedElement.className = checkedCssClassName;
        <span class="keyword">else</span>
            selectedElement.className = uncheckedCssClassName;
    }
}</pre>
<p>For Example:</p>
<p class="uncheckedStyle" id="exDiv">
<input id="exCb" onclick="replaceCssClassOnElementBasedOnCheckBoxState('exCb', 'exDiv', 'checkedStyle', 'uncheckedStyle')" name="exCb" type="checkbox" /><label for="exCb">Check This!</label></p>
<p>The style of this div should change based on the state of the checkbox.</p>
]]></content:encoded>
			<wfw:commentRss>http://sbiefeld.com/2008/11/javascript-to-change-css-class-based-on-check-box-state/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

