title: Calculating tax using javascript
body: <p>So my question is how do I add the function calculate() to the HTML code for the tax input to dynamically change. For example, if I'd write in 10'000 in the income field, the tax should show 3'500, and if I additionally added 10'000 in the wealth field, the tax should show 5'000.</p>
  
  <p>HTML:</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>var income = document.getElementById('income').value;
  var wealth = document.getElementById('wealth').value;
  var tax = document.getElementById('tax');
  
  function calculate() {
    tax.innerHTML = (0.35 * income) + (0.25 * wealth);
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="row"&gt;
    &lt;div class="col1"&gt;
      &lt;label for="income"&gt;Income:&lt;/label&gt;
    &lt;/div&gt;
    &lt;div class="col2"&gt;
      &lt;input type="number" name="income" min="0" id="income" oninput="calculate()" required&gt;&lt;br&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="row"&gt;
    &lt;div class="col1"&gt;
      &lt;label for="wealth"&gt;Wealth:&lt;/label&gt;
    &lt;/div&gt;
    &lt;div class="col2"&gt;
      &lt;input type="number" name="wealth" min="0" id="wealth" oninput="calculate()" required&gt;&lt;br&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="row"&gt;
    &lt;div class="col1"&gt;
      &lt;label for="tax"&gt;Tax:&lt;/label&gt;
    &lt;/div&gt;
    &lt;div class="col2"&gt;
      &lt;input type="number" name="tax" min="0" id="tax" disabled&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>