title: Creating the checkbox dynamically using JavaScript?
body: <p>I am trying to create a checkbox dynamically using following HTML/JavaScript. Any ideas why it doesn't work?</p>
  
  <pre><code>&lt;div id="cb"&gt;&lt;/div&gt;
  &lt;script type="text/javascript"&gt;
      var cbh = document.getElementById('cb');
      var val = '1';
      var cap = 'Jan';
  
      var cb = document.createElement('input');
      cb.type = 'checkbox';
      cbh.appendChild(cb);
      cb.name = val;
      cb.value = cap;
      cb.appendChild(document.createTextNode(cap));
  &lt;/script&gt;
  </code></pre>