I am currently developing a calculator and I want it to round the results to approximately 5 decimal places. Below is the JavaScript code snippet I have written to take input and generate output:
<div class="input">
Price paid per share: <input id="value1" type="text" /><br>
Number of shares bought: <input id="value2" type="text" /><br>
Commission/ fee's paid: <input id="value3" type="text" /><br>
<center><input type="submit" class="submit" onclick="output();"></center>
</div>
<center><p class="result" id="result"> </p></center>
<script type="text/javascript" language="javascript" charset="utf-8">
function output(){
var value1 = document.getElementById('value1').value;
var value2 = document.getElementById('value2').value;
var value3 = document.getElementById('value3').value;
document.getElementById('result').innerHTML = ((parseFloat(value1) * parseFloat(value2)) + (parseFloat(value3))) / (parseFloat(value2));
}
Does anyone have any suggestions on how I can round the output or results to around 5 decimal places? Thank you.