I am trying to set the value of an input box to be that of another input boxes' value times the price of an item. I have the currency wrapped in a span tag with a class. I need to multiply that value times the .productTextInput
input text box. That value will show in the .subTotal
box. How do I accomplish this?
jQuery:
$(".productTextInput").each(function() {
$(this).change(function() {
var priceAmount = $(this).parents().find(".priceAmount").text();
$(this).parents().find(".subTotal").val(parseInt($(this).val(), 10) * parseInt(priceAmount, 10));
});
});
html:
<table class="productTable productSmall" cellspacing="0">
<tbody>
<tr>
<td style="width: 27%;">
<strong>American (wild) plum</strong>
</td>
<td class="custom-tag"></td>
<td class="custom-tag">
Prunus americana
</td>
<td class="custom-tag">
Bare Root
</td>
<td class="custom-tag" style="border-right: 2px solid #000;">
2' - 3' size
</td>
<td style="text-align:right;padding-right: 10px;">
$<span class="priceAmount">1.75</span>
</td>
<td class="quantity">
<input id="Units_4996263" class="productTextInput" name="AddToCart_Amount" value="1" type="text">
</td>
<td>
<input class="subTotal" name="subTotal" readonly="readonly" type="text">
</td>
</tr>
</tbody>
</table>