<?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"
	>
<channel>
	<title>Comments on: Change textarea text color with checkbox and javascript</title>
	<atom:link href="http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/</link>
	<description></description>
	<pubDate>Fri, 05 Dec 2008 02:52:00 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Ed</title>
		<link>http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/#comment-12988</link>
		<dc:creator>Ed</dc:creator>
		<pubDate>Mon, 25 Oct 2004 08:36:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/#comment-12988</guid>
		<description>It is possible to access an object with an id attribute. But!!!
Is it possible to change the id attribute's value in javascript code??</description>
		<content:encoded><![CDATA[<p>It is possible to access an object with an id attribute. But!!!<br />
Is it possible to change the id attribute&#039;s value in javascript code??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jennifer</title>
		<link>http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/#comment-11326</link>
		<dc:creator>Jennifer</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/#comment-11326</guid>
		<description>Here's a more "flexible" function:&lt;h3&gt;&#60;script type="text/javascript"&#62;
function greyText(chboxname, textareaname) {
if (chboxname.checked) {
	textareaname.style.color = "#000";
} else {
	textareaname.style.color = "#999";
}
}
&#60;/script&#62;&lt;/h3&gt;Called like this&lt;h3&gt;&#60;input name="showit" type="checkbox" value="" onclick="greyText(document.myformname.showit,document.myformname.mytext)" /&#62;&lt;/h3&gt;</description>
		<content:encoded><![CDATA[<p>Here&#039;s a more &#034;flexible&#034; function:<br />
<h3>&lt;script type=&#034;text/javascript&#034;&gt;<br />
function greyText(chboxname, textareaname) {<br />
if (chboxname.checked) {<br />
	textareaname.style.color = &#034;#000&#034;;<br />
} else {<br />
	textareaname.style.color = &#034;#999&#034;;<br />
}<br />
}<br />
&lt;/script&gt;</h3>
<p>Called like this<br />
<h3>&lt;input name=&#034;showit&#034; type=&#034;checkbox&#034; value=&#034;" onclick=&#034;greyText(document.myformname.showit,document.myformname.mytext)&#034; /&gt;</h3>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jennifer</title>
		<link>http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/#comment-11327</link>
		<dc:creator>Jennifer</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/#comment-11327</guid>
		<description>getting there... I think this is even better:&lt;h3&gt;&#60;script type="text/javascript"&#62;
function greyText(chboxname, textareaname) {
if (document.myformname[chboxname].checked) {
	document.myformname[textareaname].style.color = "#000";
} else {
	document.myformname[textareaname].style.color = "#999";
}
}
&#60;/script&#62;&lt;/h3&gt;checkbox calls it like this:&lt;h3&gt;&#60;input name="showit" type="checkbox" value="" onclick="greyText('showit','mytext')" /&#62;&lt;/h3&gt;</description>
		<content:encoded><![CDATA[<p>getting there&#8230; I think this is even better:<br />
<h3>&lt;script type=&#034;text/javascript&#034;&gt;<br />
function greyText(chboxname, textareaname) {<br />
if (document.myformname[chboxname].checked) {<br />
	document.myformname[textareaname].style.color = &#034;#000&#034;;<br />
} else {<br />
	document.myformname[textareaname].style.color = &#034;#999&#034;;<br />
}<br />
}<br />
&lt;/script&gt;</h3>
<p>checkbox calls it like this:<br />
<h3>&lt;input name=&#034;showit&#034; type=&#034;checkbox&#034; value=&#034;" onclick=&#034;greyText(&#039;showit&#039;,'mytext&#039;)&#034; /&gt;</h3>
]]></content:encoded>
	</item>
	<item>
		<title>By: jayseae</title>
		<link>http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/#comment-11328</link>
		<dc:creator>jayseae</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/#comment-11328</guid>
		<description>Instead of changing the color, you may want to change the disabled method instead, so that it actually can't be used.  Something like this should work:

document.getElementById(textareaname).disabled = !(document.getElementById(chboxname).checked);

In other words, set the disabled attribute to the opposite of the checked value.  If checked, disabled is false (ie, it works).  If not checked, disabled is true (it works).  The getElementById is just what I use for xhtml compatibility.  You can use it if you add an "id" attribute to your fields.   Otherwise your code will be fine - just change the method from .style to .disabled.</description>
		<content:encoded><![CDATA[<p>Instead of changing the color, you may want to change the disabled method instead, so that it actually can&#039;t be used.  Something like this should work:</p>
<p>document.getElementById(textareaname).disabled = !(document.getElementById(chboxname).checked);</p>
<p>In other words, set the disabled attribute to the opposite of the checked value.  If checked, disabled is false (ie, it works).  If not checked, disabled is true (it works).  The getElementById is just what I use for xhtml compatibility.  You can use it if you add an &#034;id&#034; attribute to your fields.   Otherwise your code will be fine - just change the method from .style to .disabled.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jennifer</title>
		<link>http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/#comment-11329</link>
		<dc:creator>Jennifer</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/#comment-11329</guid>
		<description>jayseae - am I doing something wrong - or will that code just not work in firefox?

It probably isn't a big deal, most of the people using the page I'm working on right now, will almost certainly be on IE, but I was just wondering...</description>
		<content:encoded><![CDATA[<p>jayseae - am I doing something wrong - or will that code just not work in firefox?</p>
<p>It probably isn&#039;t a big deal, most of the people using the page I&#039;m working on right now, will almost certainly be on IE, but I was just wondering&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jayseae</title>
		<link>http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/#comment-11330</link>
		<dc:creator>jayseae</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/#comment-11330</guid>
		<description>It ought to work in Firefox - I actually took it out of an extension I wrote for Firefox and changed it to your field names.

As is, it requires IDs on your fields.  So as long as you have id="mytext" and id="showit" in the appropriate places, it should work fine.  You can even do without the function by doing it like this:

&lt;i&gt;&#60;form name="formname"&#62;
&#60;input id="showit" checked="checked" name="showit" type="checkbox" onclick="document.getElementById('mytext').disabled = !(this.checked);" /&#62; Show this paragraph&#60;br /&#62;
&#60;textarea id="mytext" name="mytext" wrap="virtual" style="color:#000;"&#62;Lorem ipsum dolor sit amet no nummy blah blah blah....&#60;/textarea&#62;
&#60;/form&#62;&lt;/i&gt;

Note the &lt;b&gt;id&lt;/b&gt; attribute on each field, and also the &lt;b&gt;checked&lt;/b&gt; attribute on the checkbox.  Otherwise it will start off un-checked, and you won't be able to see a difference when you check it.</description>
		<content:encoded><![CDATA[<p>It ought to work in Firefox - I actually took it out of an extension I wrote for Firefox and changed it to your field names.</p>
<p>As is, it requires IDs on your fields.  So as long as you have id=&#034;mytext&#034; and id=&#034;showit&#034; in the appropriate places, it should work fine.  You can even do without the function by doing it like this:</p>
<p><i>&lt;form name=&#034;formname&#034;&gt;<br />
&lt;input id=&#034;showit&#034; checked=&#034;checked&#034; name=&#034;showit&#034; type=&#034;checkbox&#034; onclick=&#034;document.getElementById(&#039;mytext&#039;).disabled = !(this.checked);&#034; /&gt; Show this paragraph&lt;br /&gt;<br />
&lt;textarea id=&#034;mytext&#034; name=&#034;mytext&#034; wrap=&#034;virtual&#034; style=&#034;color:#000;&#034;&gt;Lorem ipsum dolor sit amet no nummy blah blah blah&#8230;.&lt;/textarea&gt;<br />
&lt;/form&gt;</i></p>
<p>Note the <b>id</b> attribute on each field, and also the <b>checked</b> attribute on the checkbox.  Otherwise it will start off un-checked, and you won&#039;t be able to see a difference when you check it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jennifer</title>
		<link>http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/#comment-11331</link>
		<dc:creator>Jennifer</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/#comment-11331</guid>
		<description>Ah! Yes, with "Id" it works. :)
Thx!!</description>
		<content:encoded><![CDATA[<p>Ah! Yes, with &#034;Id&#034; it works. <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Thx!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: meghan's dolphin</title>
		<link>http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/#comment-11332</link>
		<dc:creator>meghan's dolphin</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/#comment-11332</guid>
		<description>&lt;trackback /&gt;&lt;strong&gt;Daily Dose of Development&lt;/strong&gt;
Script snippet: Change textarea text color with checkbox and javascript...</description>
		<content:encoded><![CDATA[<trackback /><strong>Daily Dose of Development</strong><br />
Script snippet: Change textarea text color with checkbox and javascript&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Code Novice</title>
		<link>http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/#comment-11333</link>
		<dc:creator>Code Novice</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2004/05/07/change-textarea-text-color-with-checkbox-and-javascript/#comment-11333</guid>
		<description>&lt;trackback /&gt;&lt;strong&gt;Scripty's Text Area Twofer&lt;/strong&gt;
I'm creating a proposal for a possible corporate client and...
</description>
		<content:encoded><![CDATA[<trackback /><strong>Scripty&#039;s Text Area Twofer</strong><br />
I&#039;m creating a proposal for a possible corporate client and&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.312 seconds -->
