Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I disagree with the people telling you to use <code>disabled='disabled'</code> The disabled property on input elements takes a boolean, unlike the HTML attribute. <a href="https://developer.mozilla.org/en/DOM/HTMLInputElement" rel="nofollow">https://developer.mozilla.org/en/DOM/HTMLInputElement</a></p> <p>From the names of the variables you're passing into <code>enableCheckBox</code>, it looks like you're passing DOM nodes instead of ids.</p> <p>Another problem is that you're passing <code>this.ID</code>, you should be passing <code>this.id</code>. Even better, just pass the element itself. See this example <a href="http://jsfiddle.net/mendesjuan/7ZEvk/2/" rel="nofollow">http://jsfiddle.net/mendesjuan/7ZEvk/2/</a></p> <p>The last problem (in initial example) was that you were trying to set an <code>enabled</code> property, but that doesn't exist. You have to set the <code>disabled</code> property.</p> <p>HTML</p> <pre><code>&lt;input type='checkbox' id='cbox' onclick="enableCheckBox(this, 'text1', 'text2', 'text3', 'sel');"/&gt; &lt;input id='text1' /&gt; &lt;input id='text2' /&gt; &lt;input id='text3' /&gt; &lt;select id='sel'&gt; &lt;option&gt;hello&lt;/option&gt; &lt;/select&gt; </code></pre> <p>JavaScript</p> <pre><code>// This is a lot like your function, but is less repetitive function enableCheckBox(cbox /*, ... ids of fields to enable/disable */){ for (var i = 1; i &lt; arguments.length; i++) { document.getElementById(arguments[i]).disabled = cbox.checked; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload