title: how to auto calculate fields in inputs?
body: <p>I am trying to auto calculate the discount amount by filling in two input fields but I don't know what am I doing wrong. What I want is that as I fill both inputs it appears the result in a third input.</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-html lang-html prettyprint-override"><code>&lt;div class="form-group col-md-2"&gt;
    &lt;label for="sale_price"&gt;Precio de Venta&lt;/label&gt;
    &lt;input type="number" pattern="[0-9]+([\.,][0-9]+)?" step="00.01" name="sale_price" class="form-control" id="saleP" onkeyup="discount();"&gt;
  &lt;/div&gt;
  
  
  &lt;div class="form-group col-md-3"&gt;
    &lt;label for="discount_percentage"&gt;Porcentaje de descuento (%)&lt;/label&gt;
    &lt;input type="number" name="discount_percentage" class="form-control" id="discountP" onkeyup="discount();"&gt;
  &lt;/div&gt;
  
  &lt;div class="form-group col-md-3"&gt;
    &lt;label for="discount"&gt;Descuento&lt;/label&gt;
    &lt;input type="number" name="discount" placeholder="discount" class="form-control"&gt;
  &lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
    function discount() {
      var x;
      (document.getElementById('saleP').document.getElementById('discountP')) / 100 = x
    }
  &lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>Does anyone knows what I am doing wrong?</p>