JSFiddle - React, Tailwind, and code Playground
HTML
<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>