How to multiplication array input and display result. If input order, the price will multiplication with order and display subtotal. The problem is I have more than one subtotal
<table>
<tr>
<td>Price</td>
<td>Order</td>
<td>Subtotal</td>
</tr>
<tr>
<td><input type="text" id="price1" name="price" readonly="" value="15000"></td>
<td><input type="text" id="order1" name="order" value="0" oninput="subt()"></td>
<td><input type="text" name="subtotal" value="0" readonly></td>
</tr>
<tr>
<td><input type="text" id="price2" name="price" readonly="" value="10000"></td>
<td><input type="text" id="order2" name="order" value="0" oninput="subt()"></td>
<td><input type="text" name="subtotal" value="0" readonly></td>
</tr>
<tr>
<td><input type="text" id="price3" name="price" readonly="" value="5000"></td>
<td><input type="text" id="order3" name="order" value="0" oninput="subt()"></td>
<td><input type="text" name="subtotal" value="0" readonly></td>
</tr>
Javascript
function subt(){
var price = document.getElementsByName('price'),
order = document.getElementsByName('order'),
subtotal = document.getElementsByName('subtotal');
var sub=0;
for(var i=0;i<price.length;i++){
sub += price[i] * order[i];
document.getElementByName('subtotal').value = sub;
}
}