title: Calculate with formula javascript
body: <p>Lately i want to make a converter formula with javascript. but i got a stack at this function </p>
  
  <blockquote>
    <p>javascript</p>
  </blockquote>
  
  <pre><code>function UconverterDP(){
              var inputD = document.getElementById('inputD').value;
              var inputP = document.getElementById('inputP').value;
              jikaP = inputD * 0.4;
              bagianatasU1 = 0.8 * inputP * inputD;
              bagianbawahU1 = P + (0.4 * inputD);
              hasilU1 = bagianatasU1 / bagianbawahU1;
              bagaianatasU2 = 0.8 * inputD;
              bagaianatasU2a =  1 - bagaianatasU2 ;                                       
              bagaianatasU2h = inputP - bagaianatasU2a;
              bagianbawahU2 = 0.0114 * inputP;
              bagianbawahU2a = Math.pow(bagianbawahU2, 1.7);
              bagianbawahU2b = 0.92 * bagianbawahU2a;
              bagianbawahU2h = bagianbawahU1 * bagianbawahU2b;
              hasilU2 = bagaianatasU2h / bagianbawahU2h;
              if (inputP &lt;= jikaP) {
              document.getElementById("outputU").innerHTML = Hasil U1;    
              } else {
              document.getElementById("outputU").innerHTML = hasilU2;
              }
          }   
  </code></pre>
  
  <p>this my input </p>
  
  <pre><code>&lt;tr&gt;
      &lt;td&gt;
          &lt;label&gt;D : &lt;/label&gt;
          &lt;input id="inputD" type="number" onchange="UconverterDP()"&gt;
      &lt;/td&gt;
      &lt;td&gt;
          &lt;label&gt;P : &lt;/label&gt;
          &lt;input id="inputP" type="number" onchange="UconverterDP()"  &gt;
      &lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>and this output</p>
  
  <pre><code>&lt;label&gt; BUI (U): &lt;/label&gt;
  &lt;span id="outputU"&gt;&lt;/span&gt;
  </code></pre>
  
  <p>And this is the formula:</p>
  
  <p><a href="https://i.stack.imgur.com/JZarC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JZarC.png" alt="enter image description here"></a></p>