title: Disable table using checkbox
body: <p>I have this checkbox, how to disable a table (disable all the input fields in the table) whenever I check the checkbox?</p>
  
  <pre><code>&lt;label&gt;&lt;input type="checkbox" name="view" value="d"&gt;N/A&lt;/label&gt; 
  </code></pre>
  
  <p>Is it possible using purely JavaScript and not jQuery.</p>
  
  <p>This is the code now</p>
  
  <pre><code>var elems = document.getElementById('table-id').querySelectorAll('input,select,textarea');
  document.getElementById('check').onchange = function () {
      if (document.getElementById('check').checked) {
          for (var i = 0; i &lt; elems.length; i++) {
              elems[i].disabled = true;
          }
      } else {
          for (var i = 0; i &lt; elems.length; i++) {
              elems[i].disabled = false;
          }    
          }
      }
  </code></pre>
  
  <p>and the table</p>
  
  <pre><code>&lt;table id='table-id' border="1"&gt;
  </code></pre>
  
  <p>but it shows error like this:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'querySelectorAll' of null </p>
  </blockquote>