I have some code for dynamic form on yii2, but I use dynamic form for add more form, and I want to add with jQuery but dynamic form change id if I add more form, and jQuery is not working on another form.
<script type="text/javascript" src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#transactiondetails-0-jumlah, #transactiondetails-0-harga').keyup(function() {
var jumlah = $('#transactiondetails-0-jumlah').val();
var harga = $('#transactiondetails-0-harga').val();
var total = jumlah * harga;
$('#transactiondetails-0-total').val(total);
});
});
</script>
I want change > "transactiondetails-0-jumlah" to transactiondetails-1-jumlah and more, and how to do looping on jQuery to change the id number