title: JavaScript checkbox onclick function
body: <p>I am stuck at the simple JavaScript function, related to the checkbox validation. I need to document.write if the cb1 is checked, and the same if cb2. And if both, or one of them isn't checked, then write nothing.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;TEST PAGE&lt;/title&gt;
      &lt;script type="text/javascript" src="submit.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div style="width:100%"&gt;&lt;input type="checkbox" id="cb1"&gt;&lt;/div&gt;
      &lt;div style="width:100%"&gt;&lt;input type="checkbox" id="cb2"&gt;&lt;/div&gt;
  
      &lt;div style="width:100%"&gt;&lt;input type="submit" name="execute" id="execute" value="Execute" onClick="run();"&gt;&lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>submit.js</p>
  
  <pre><code>function run() {
  
      document.write('&lt;div&gt;' + "HERE GOES YOUR CHECKBOX CHOICE: " + '&lt;/div&gt;');
  
      if(document.getElementById("cb1").checked == true) {
          document.write("This is check box 1");
      }
      if(document.getElementById("cb2").checked == true) {
          document.write("This is check box 2");
      }
  }
  </code></pre>