title: How to remove unchecked item from textbox?
body: <p>My JavaScript:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function getVal(chk, adto)
  {
    var ad="";
    if (chk.checked) 
    {
      ad=document.getElementById(adto).value + chk.value;
      document.getElementById(adto).value = ad;
    }
    else  
    {
    }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>The first block is working as I wanted but when user unchecked the check box it should remove the value from the text box.</p>
  
  <p>Below is the HTML code:</p>
  
  <pre><code>&lt;body&gt;
  &lt;input type="checkbox" name="chk[]" value="0" id="chk0" onclick="getVal(this, 'inp0')"&gt;value 0&lt;br&gt;
  &lt;input type="checkbox" name="chk[]" value="1" id="chk1" onclick="getVal(this, 'inp0')"&gt;value 1&lt;br&gt;
  &lt;input type="checkbox" name="chk[]" value="2" id="chk2" onclick="getVal(this, 'inp0')"&gt;value 2&lt;br&gt;
  &lt;input type="checkbox" name="chk[]" value="3" id="chk3" onclick="getVal(this, 'inp0')"&gt;value 3&lt;br&gt;
  &lt;input type="checkbox" name="chk[]" value="4" id="chk4" onclick="getVal(this, 'inp0')"&gt;value 4&lt;br&gt;
  &lt;input type="checkbox" name="chk[]" value="5" id="chk5" onclick="getVal(this, 'inp0')"&gt;value 5&lt;br&gt;
  &lt;br&gt;
  &lt;input type="text" name="inp" id="inp0" readonly&gt;&lt;br&gt;
  </code></pre>
  
  <p>Please help how to remove the unchecked options from the text box.</p>