title: add checkbox on input type number change
body: <p>I would like to know how to add checkboxes on input type number change.</p>
  
  <p>By default I have :</p>
  
  <p><strong>HTML CODE</strong></p>
  
  <pre><code>&lt;label for checkbox_number&gt;Number of checkboxes :&lt;/label&gt;
  &lt;input id="checkbox_number" name="checkbox_number" type="number" size="1" maxlength="1" value="1" onkeydown="change_cb()"/&gt;
  
  &lt;input id="checkbox1" type="checkbox" name="checkbox[]" value="cb1"&gt;
  </code></pre>
  
  <p>If I change my <em>checkbox number</em> to 2, I would like javascript/ajax add</p>
  
  <pre><code>&lt;input id="checkbox2" type="checkbox" name="checkbox[]" value="cb2"&gt;
  </code></pre>
  
  <p>Same as if I change my <em>change number</em> to 1, it has to remove one checkbox.</p>
  
  <p>I already did same thing but with table (add one row or remove one row) but here i don't know how to add new element (on my first script I don't add new table, just new row)...</p>
  
  <p>Need help to write my JS function <strong>change_cb()</strong></p>
  
  <hr>
  
  <p><strong>EDIT TO GIVE YOU MY ANSWER</strong></p>
  
  <p>I find how to do this with DADE help (thank you DADE) :</p>
  
  <p><strong>HTML CODE (same)</strong></p>
  
  <pre><code>&lt;label for="cb_number"&gt;How many checkboxes ?&lt;/label&gt;
  &lt;input id="cb_number" name="cb_number" type="number" size="1" maxlength="1" value="1"&gt;
  &lt;div class="my_cb_result"&gt;&lt;/div&gt;
  </code></pre>
  
  <p><strong>jQuery CODE</strong></p>
  
  <pre><code>$(window).ready(function() {
      $('#cb_number').on('keyup mouseup', function() {
          var number = parseInt($(this).val());
          $('input[type="checkbox"]').remove();
          $('label[class="to_del"]').remove();
          for (var i=1;i&lt;=number;i++) {
              var data = '&lt;label for="checkbox" class="to_del"&gt;Label of my checkbox&lt;/label&gt;&lt;input id="checkbox'+i+'" type="checkbox" name="checkbox[]" value="'+i+'"&gt;';
          }
          $('.my_cb_result').append(data);
      });
  });
  </code></pre>
  
  <p><a href="http://jsfiddle.net/2CtNv/" rel="nofollow">JSFiddle with comments</a></p>