title: How to calculate formula from string to int
body: <p>I have a table that contains formula. Example of the formula: </p>
  
  <p><strong>(GP1/(GP1 + GP2))*100%.</strong></p>
  
  <p>In my code using <strong>jquery</strong>, i will replace GP1 with textbox1 value, GP2 with textbox2 value and remove the %.</p>
  
  <p>I try to get the result by doing this:</p>
  
  <pre><code>var repl1 = (GP1/(GP1 + GP2))*100%;
  var repl2 = repl1.replace(/GP1/gi,parseInt($("#txtbox1").val()));
  var repl3 = repl2.replace(/GP2/gi,parseInt($("#txtbox2").val()));
  var repl4 = repl3.replace(/%/gi,"");
  </code></pre>
  
  <p>==> so the last result will be:</p>
  
  <pre><code> var repl4 = (10/(10+0))*100
  </code></pre>
  
  <p>I try to convert it to be int by doing this:</p>
  
  <pre><code>var result = parseInt(repl4);
  </code></pre>
  
  <p>But i get the result <strong>NaN</strong>.</p>
  
  <p>Can anybody help me on how to calculate the formula</p>
  
  <p>Thank you.</p>