So my question is how do I add the function calculate() to the HTML code for the tax input to dynamically change. For example, if I'd write in 10'000 in the income field, the tax should show 3'500, and if I additionally added 10'000 in the wealth field, the tax should show 5'000.
HTML:
var income = document.getElementById('income').value;
var wealth = document.getElementById('wealth').value;
var tax = document.getElementById('tax');
function calculate() {
tax.innerHTML = (0.35 * income) + (0.25 * wealth);
}
<div class="row">
<div class="col1">
<label for="income">Income:</label>
</div>
<div class="col2">
<input type="number" name="income" min="0" id="income" oninput="calculate()" required><br>
</div>
</div>
<div class="row">
<div class="col1">
<label for="wealth">Wealth:</label>
</div>
<div class="col2">
<input type="number" name="wealth" min="0" id="wealth" oninput="calculate()" required><br>
</div>
</div>
<div class="row">
<div class="col1">
<label for="tax">Tax:</label>
</div>
<div class="col2">
<input type="number" name="tax" min="0" id="tax" disabled>
</div>
</div>