Greetings, I have a problem showing the total of an operation that I do between two inputs, the result of that operation I must show it in another input automatically, without pressing a button or anything, these are my inputs:
$(document).ready(function() {
$("#monto").change(function() {
var acumulado = parseInt(0);
function calcula() {
var cantidad = parseInt($("#num").val());
var monto = parseInt($("#monto").val());
var vecesPorcentaje = Math.floor(cantidad / 3);
var sobrantes = cantidad - (vecesPorcentaje * 3);
for (var i = 0; i < vecesPorcentaje; i++) {
acumulado = acumulado + (monto * 3);
monto = monto + (monto * 0.2);
}
acumulado = acumulado + (monto * sobrantes);
$("#total").val(acumulado);
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form action="" method="POST">
<input type="text" id="num" placeholder="cantidad"><br><br>
<input type="text" id="monto" placeholder="monto"><br><br>
<input type="text" id="total" disabled value="">
</form>
I am looking for the total of the operation to appear automatically as long as I am writing in the input with id="amount" but it is not showing me anything and it does not give errors in console.