I have dynamic multiple input inside table.
I want to add event on every id textbox, add event on every quantity too and call ajax. last, add event on subtotal when value change, add new row multiple input.
can you help me please?<td><input type="text" maxlength="13" name="id[]" id="id" required></td>
<td><input type="text" name="name[]" id="name" readonly required></td>
<td><input type="text" name="quantity[]" id="quantity" required></td>
<td><input type="text" name="price[]" id="price" readonly required></td>
<td><input type="text" name="subtotal[]" id="subtotal" readonly required></td>
<script>
$(document).ready(function(){
$("#id").each(function(index, item){
$(item).on("change paste keyup", function(){
var id = $(this).val();
$.ajax({
dataType: 'json',
url:"load_product.php",
method:"POST",
data:{id:id},
success:function(data) {
$('#name').val(data.name);
$('#price').val(data.price);
}
});
});
});
$("#quantity").on("change paste keyup", function(){
var qty = $(this).val();
var price = $('#price').val();
var subtotal = qty * price;
$('#subtotal').val(subtotal);
});
});
</script>

#idshould be unique,$("#id").each(...)could causeselectorerrors. Better to use classesclass="input-id", class="input-name", etc...