I have following HTML code:
<table>
<th>Items</th><th>Rate</th><th>Quantity</th>
<tr><td>Item A</td><td>20</td><td><input type="text" id="txtItemA"/></td></tr>
<tr><td>Item B</td><td>10</td><td><input type="text" id="txtItemB"/></td></tr>
<tr><td>Item C</td><td>30</td><td><input type="text" id="txtItemC"/></td></tr>
<tr><td>Total Price</td><td><input type="text" id="txtPrice"/></td></tr>
</table>
On the onblur event of textboxes, I want to call a javascript function which will multiply the quantity added by the user to the rate and display it in txtPrice textbox. But I am stuck in the logic that how should I pick the rate corresponding to the quantity entered.
For example: When I enter 2 in txtItemA textbox, 40 should get displayed in txtPrice textbox. Javascript function is simple it will just multiply rate with quantity entered and display it in txtPrice.
What should I do to get to fetch the associated rate against the quantity and pass it to javascript function?
Javascript function
function DisplayTotal(rate, quantity)
{
document.getElementById('txtPrice').innerText = rate * quantity;
}