I have a page which can have multiple rows with 4 input fields on each, like this
1.Number of units 2.Unit price 3.Discount rate 4.Total
I'd like to perform calculations based on the field values. As the user enters values I'd like to update the fourth field (total) depending on the values entered in the boxes, the fourth field shall not be editable by the user. If the discount rate is empty or that field shall be ignored.
To clarify, the total field shall only be updated once there are values in both the amount and price fields. Also the total field shall display the total with the discount deducted if a number is entered into the discount field.
Unfortunately I have no clue and am hoping for some help here.
The rows on the page can vary, the user can add/delete rows to the page (this is already in place)
the html looks like below, and here is a jsfiddle
<div class="row">
<div>
<input class="form-control" id="num-of-prods-1" type="text" placeholder="Number of units">
</div>
<div>
<input class="form-control" id="prod-unit-price-1" type="text" placeholder="Unit price">
</div>
<div>
<input class="form-control" id="discount-rate-1" type="text" placeholder="Discount rate %">
</div>
<div>
<input class="form-control" id="order-amount-1" type="text" placeholder="Total">
</div>
</div>
<div class="row">
<div>
<input class="form-control" id="num-of-prods-2" type="text" placeholder="Number of units">
</div>
<div>
<input class="form-control" id="prod-unit-price-2" type="text" placeholder="Unit price">
</div>
<div>
<input class="form-control" id="discount-rate-2" type="text" placeholder="Discount rate %">
</div>
<div>
<input class="form-control" id="order-amount-2" type="text" placeholder="Total">
</div>
</div>