I have a form where users can create unlimited number of rows (using jquery- add new row) to add multiple products information. When they create new rows the code looks like following.
Now what I am trying to do is when every time an user puts the value of product quantity and product price I want to instantly calculate the total (product quantity* product price) and put the result in the total[] input and then adjust the total amount input which is at the bottom of the form.
I know how to do this when I have fixed amount of inputs using jquery, but since the amount of inputs are not fixed in this situation I have any idea on how to achieve this.
Could you please show me?
Thanks in Advance 🙂
<tr>
<td><input type="text" name="name[]" id="name_1" value=""></td>
<td><input type="text" name="quantity[]" id="quantity_1" value=""></td>
<td><input type="text" name="rate[]" id="rate_1" value=""></td>
<td><input type="text" name="total[]" id="total_1" value=""></td>
</tr>
<tr>
<td><input type="text" name="name[]" id="name_2" value=""></td>
<td><input type="text" name="quantity[]" id="quantity_2" value=""></td>
<td><input type="text" name="rate[]" id="rate_2" value=""></td>
<td><input type="text" name="total[]" id="total_2" value=""></td>
</tr>
<!-- I have N number of rows like above. and at the bottom I have input for total -->
<tr>
<td> </td>
<td> </td>
<td> </td>
<td><input type="text" name="totalamount" id="totalamount" value=""></td>
</tr>
Here is one possible solution:
DEMO: http://jsfiddle.net/ak49E/