title: Add or remove input field, depending on checkbox, using JavaScript
body: <p>I have <code>&lt;form&gt;</code> element with some <code>textfields</code> and <code>selections</code>, so I want several new <code>&lt;input type="text"&gt;</code> to be added, when a <code>checkbox</code> is checked and delete them, when it's unchecked. </p>
  
  <p>What is best way to do so?</p>
  
  <p>Is it possible to assign new element to variable or object and then use this variable or object as a reference to delete new elements, because it's supposed several elements to be added at the same time (e.g. <code>&lt;br&gt;&lt;inpit type="text"&gt;</code>), and I think, that adding them separately is not the best way, so deleting too.</p>
  
  <p>I'm using JQuery as a framework.</p>
  
  <pre><code>&lt;form name="add_subject"&gt;
  
  &lt;table cellspacing="1"&gt;
      &lt;tr&gt;
          &lt;td class="key"&gt;Day&lt;/td&gt;
          &lt;td class="value"&gt;
              &lt;select size="7" name="day"&gt;
                  &lt;option value="1"&gt;...&lt;/option&gt;
                  &lt;option value="2"&gt;...&lt;/option&gt;
              &lt;/select&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class="key"&gt;Groups&lt;/td&gt;
          &lt;td class="value"&gt;
              &lt;input type="checkbox" name="sg"&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class="key"&gt;Lecture&lt;/td&gt;
          &lt;td class="value"&gt;
              &lt;input type="text" size="50" maxlength="50" name="lec1"&gt; /***/
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class="key"&gt;Auditory&lt;/td&gt;
          &lt;td class="value"&gt;
              &lt;input type="text" size="4" maxlength="4" name="aud1"&gt; /***/
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p></p>
  
  <p>I want to add <code>&lt;br&gt;&lt;input type="text"&gt; : &lt;input type="text"&gt;</code> after existing <code>&lt;input&gt;</code> field, where <code>/***/</code> is given, when the checkbox is cheked and remove, when it's not.</p>
  
  <p>What is the best way?</p>
  
  <p>Thanks!</p>