So I'm trying to assign the result value(from user input Unit_Price_1 * Quantity_1) to the total text field for each row. I get it to work for my first row but cant work for my second row ?, Kinda still a noob trying to do something with my idea
HTML code :
<table>
<thead>
<tr>
<th>Unit Price</th>
<th>Quantity</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<!---------------- ROW 1 ------------------>
<td>
<input type="number" name="unit price" placeholder="0.00" id="Unit Price_1" oninput="calculateTotal()"/>
</td>
<td>
<input type="number" name="Quality" placeholder="0" id="Quantity_1" oninput="calculateTotal()"/>
</td>
<td>
<input
required
type="number"
name="total"
value="0.00"
readonly="readonly"
id="Total_1"
/>
</td>
</tr>
<!---------------- ROW 2 ------------------>
<td>
<input type="number" name="unit price" placeholder="0.00" id="Unit Price_1" oninput="calculateTotal()"/>
</td>
<td>
<input type="number" name="Quality" placeholder="0" id="Quantity_1" oninput="calculateTotal()"/>
</td>
<td>
<input
required
type="number"
name="total"
value="0.00"
readonly="readonly"
id="Total_1"
/>
</td>
</tr>
</tbody>
JavaScript:
function calculateTotal() {
var Unit_Price_1 = document.getElementById('Unit Price_1').value;
var Quantity_1 = document.getElementById('Quantity_1').value;
var Total_1 = document.getElementById('Total_1')
var Total_Amount_1 = Unit_Price_1 * Quantity_1;
Total_1.value = Total_Amount_1
}