title: Difference between two input value without button
body: <p>I have a form i have 2 select menu and one input menu </p>
  
  <pre><code>&lt;form method="post" action=""&gt;
     &lt;label class="col-sm-3 control-label" for="textinput"&gt;Civil Works&lt;/label&gt;  
    &lt;div class="col-sm-3"&gt;
  
      &lt;select id="cpercentage" name="txt_cpercentage" class="form-control" onkeyup="calc()"&gt;
  
        &lt;option value=""&gt;&lt;/option&gt;
          &lt;option value="0"&gt;0%&lt;/option&gt;
          &lt;option value="5"&gt;5%&lt;/option&gt;
          &lt;option value="10"&gt;10%&lt;/option&gt;
          &lt;option value="15"&gt;15%&lt;/option&gt;
          &lt;option value="20"&gt;20%&lt;/option&gt;
          &lt;option value="25"&gt;25%&lt;/option&gt;
          &lt;option value="30"&gt;30%&lt;/option&gt;
          &lt;option value="35"&gt;35%&lt;/option&gt;
          &lt;option value="40"&gt;40%&lt;/option&gt;
          &lt;option value="45"&gt;45%&lt;/option&gt;
          &lt;option value="50"&gt;50%&lt;/option&gt;
          &lt;option value="55"&gt;55%&lt;/option&gt;
          &lt;option value="60"&gt;60%&lt;/option&gt;
          &lt;option value="65"&gt;65%&lt;/option&gt;
          &lt;option value="70"&gt;70%&lt;/option&gt;
          &lt;option value="75"&gt;75%&lt;/option&gt;
          &lt;option value="80"&gt;80%&lt;/option&gt;
          &lt;option value="85"&gt;85%&lt;/option&gt;
          &lt;option value="90"&gt;90%&lt;/option&gt;
          &lt;option value="95"&gt;95%&lt;/option&gt;
          &lt;option value="100"&gt;100%&lt;/option&gt;
      &lt;/select&gt;
    &lt;/div&gt;
       &lt;label class="col-sm-3 control-label" for="textinput"&gt;Electrical Works&lt;/label&gt;  
    &lt;div class="col-sm-3"&gt;
  
      &lt;select id="epercentage" name="txt_epercentage" class="form-control"  &gt;
  
        &lt;option value=""&gt;&lt;/option&gt;
          &lt;option value="0"&gt;0%&lt;/option&gt;
          &lt;option value="5"&gt;5%&lt;/option&gt;
          &lt;option value="10"&gt;10%&lt;/option&gt;
          &lt;option value="15"&gt;15%&lt;/option&gt;
          &lt;option value="20"&gt;20%&lt;/option&gt;
          &lt;option value="25"&gt;25%&lt;/option&gt;
          &lt;option value="30"&gt;30%&lt;/option&gt;
          &lt;option value="35"&gt;35%&lt;/option&gt;
          &lt;option value="40"&gt;40%&lt;/option&gt;
          &lt;option value="45"&gt;45%&lt;/option&gt;
          &lt;option value="50"&gt;50%&lt;/option&gt;
          &lt;option value="55"&gt;55%&lt;/option&gt;
          &lt;option value="60"&gt;60%&lt;/option&gt;
          &lt;option value="65"&gt;65%&lt;/option&gt;
          &lt;option value="70"&gt;70%&lt;/option&gt;
          &lt;option value="75"&gt;75%&lt;/option&gt;
          &lt;option value="80"&gt;80%&lt;/option&gt;
          &lt;option value="85"&gt;85%&lt;/option&gt;
          &lt;option value="90"&gt;90%&lt;/option&gt;
          &lt;option value="95"&gt;95%&lt;/option&gt;
          &lt;option value="100"&gt;100%&lt;/option&gt;
      &lt;/select&gt;
    &lt;/div&gt;
           &lt;label class="col-sm-3 control-label" for="textinput"&gt;Mechanical Works&lt;/label&gt;  
    &lt;div class="col-sm-3"&gt;
      &lt;input type="text" id="mpercentage" name="txt_mpercentage" class="form-control" readonly &gt; 
  
    &lt;/div&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>I use this code in javascript to calculate the difference and this difference will be 100-(select1+select2) without click any button</p>
  
  <pre><code>&lt;script&gt;
  
  function calc() {
      var textValue1 = document.getElementById('cpercentage').value;
      var textValue2 = document.getElementById('epercentage').value;
  
      document.getElementById('mpercentage').value = 100-(textValue1 + textValue2);
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>but i don't have any result in the input field i don't know why can any body help to solve this problem 
  after a search i see this in stackoverflow <a href="https://stackoverflow.com/questions/19699642/how-to-multiply-two-values-without-clicking-a-button-javascript">link</a>
  but also didn't help</p>