[Solved] How to subtract two inputs with each another
<input id=”total” type=”text”> <input id=”v1″ type=”text”> <input id=”v2″ type=”text”> <button type=”button” onclick=”update()”>Update</button> <script> function update() { var total = parseInt(document.getElementById(“total”).value, 10); var value1 = parseInt(document.getElementById(“v1”).value, 10); var value2 = parseInt(document.getElementById(“v2”).value, 10); document.getElementById(“total”).value = total – (value1 + value2); } </script> Working example: https://jsfiddle.net/md9ebo00/5/ I would not suggest using onchange=”update” as an attribute for the two … Read more