title: How is checkDisplay triggered in this html?
body: <p>It seems the checkDisplay in the body of the page is triggered on each click of the check box. But how? The function does not seem to bind with the check box...</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Checkbox&lt;/title&gt;
  &lt;script type="text/javascript"&gt;
      var checkDisplay = function(check, form) { //check ID, form ID
          form = document.getElementById(form), check =         document.getElementById(check);
          check.onclick = function(){
              form.style.display = (this.checked) ? "block" : "none";
              form.reset();
          };
          check.onclick();
      };
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;input type="checkbox" id="check" /&gt;
  &lt;form id="form"&gt;
      &lt;input type="checkbox" /&gt;&lt;input type="text" /&gt;
  &lt;/form&gt;
  &lt;script type="text/javascript"&gt;
  checkDisplay("check", "form");
  &lt;/script&gt;
  </code></pre>
  
  <p>
      </p>