How to disable/enable form elements using a checkbox with Javascript?
<p>I'm at a loss - after wracking my brain for hours on this one, it's time to throw the question up here.</p>

<p>I'm trying to have a checkbox execute some javascript code that, when checked, enables some form elements, and when unchecked, disables those elements again.</p>

<p>Here's the javascript that I have:</p>

<pre><code>function houseclean()
{
if (document.orderform.cleaning.checked == true)
  {
  document.orderform.rooms.disabled = false;
  document.orderform.datetime.disabled = false;
  document.orderform.howoften.disabled = false;
  }
else
  {
  document.orderform.rooms.disabled = true;
  document.orderform.datetime.disabled = true;
  document.orderform.howoften.disabled = true;
  }
} 
</code></pre>

<p>And here is my HTML code:</p>

<pre><code>&lt;form id="orderform" style="margin-left: 6cm"&gt;
&lt;input type="checkbox" name="cleaning" value="yes" onclick="houseclean()"/&gt; Home cleaning &lt;br /&gt;
Service: &lt;select name="rooms" id="rooms" disabled &gt;
  &lt;option value="1bedroom"&gt;One Bedroom Apt&lt;/option&gt;
  &lt;option value="2bedroom"&gt;Two Bedroom Apt&lt;/option&gt;
  &lt;option value="3bedroom"&gt;Three Bedroom Townhome or SF Home&lt;/option&gt;
  &lt;option value="4bedroom"&gt;Four Bedroom Home&lt;/option&gt;
  &lt;option value="5bedroom"&gt;Five Bedroom Home&lt;/option&gt;
  &lt;option value="6bedroom"&gt;Six Bedroom Home&lt;/option&gt;
&lt;/select&gt; &lt;br /&gt;
Date / Time: &lt;input type="text" name="datetime" disabled /&gt;&lt;br /&gt;
How often would you like a cleaning?: &lt;select name="howoften" disabled&gt;
  &lt;option value="once"&gt;One Time Only&lt;/option&gt;
  &lt;option value="2bedroom"&gt;Every Week&lt;/option&gt;
  &lt;option value="3bedroom"&gt;Every Other Week&lt;/option&gt;
  &lt;option value="4bedroom"&gt;Once a Month&lt;/option&gt;
&lt;/select&gt; &lt;br /&gt;
&lt;/form&gt;
</code></pre>
