title: Auto substract both values from 100
body: <p>I created two input fields where they should substract from each other keeping a max value at 100.</p>
  
  <p>Currently it substracted value is shown in the second value. I want it to be interchangeable. Irrespective of whether I put in first or second input field, the answer shows in the other.</p>
  
  <p>Could someone help?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function updateDue() {
      var total = parseInt(document.getElementById("totalval").value);
      var val2 = parseInt(document.getElementById("inideposit").value);
      // to make sure that they are numbers
      if (!total) { total = 0; }
      if (!val2) { val2 = 0; }
      var ansD = document.getElementById("remainingval");
      ansD.value = total - val2;
      var val1 = parseInt(document.getElementById("inideposit").value);
      // to make sure that they are numbers
      if (!total) { total = 0; }
      if (!val1) { val1 = 0; }
      var ansD = document.getElementById("remainingval");
      ansD.value = total - val1;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;input type="hidden" id="totalval" name="totalval" value="100" onchange="updateDue()"&gt;
  &lt;div&gt;
    Enter Value:
    &lt;input type="text" name="inideposit" class="form-control" id="inideposit" onchange="updateDue()"&gt;
  &lt;/div&gt;
  &lt;div&gt;
    Substracted:
    &lt;input type="text" name="remainingval" class="form-control" id="remainingval" onchange="updateDue()"&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>