Here i have some some form group with values from database
<div class="form-group">
<label for="exampleInputTotalBayar">Total Bayar</label>
<input type="text" class="form-control" id="inputTotalBayar" placeholder="Total Bayar" name="totalBayar" value="{{ $peminjaman->totalBayar }}">
</div>
<div class="form-group">
<label for="exampleInputJumlahBayar">Jumlah Bayar</label>
<input type="text" class="form-control" id="inputJumlahBayar" onchange="" placeholder="Jumlah Bayar" name="jumlahBayar" value="{{ $peminjaman->jml_bayar }}">
</div>
Then i want to give new values in this form
<div class="form-group">
<label for="exampleInputDenda">Denda</label>
<input type="text" class="form-control" id="exampleInputDenda" placeholder="Denda" name="denda" value="{{ $peminjaman->denda }}">
</div>
so, when i give new values in form group Denda, the output will be show in here
<p>Bayar Pengembalian: <div id="bayar" name="bayar"></div></p>
My code for javascript was like this
<script type="text/javascript">
var bayar = parseInt("0");
var totalBayar = parseInt($("#inputTotalBayar").val());
var jumlahBayar = parseInt($("#inputJumlahBayar").val());
var denda = parseInt($("#exampleInputDenda").val());
$("#exampleInputDenda").change(function() {
bayar = bayar + denda + totalBayar - jumlahBayar;
$("#bayar").html(bayar);
});
but the calculation result doesn't appear, can you help me to solve this problem?