I am having a small issue calculating price from Quantity in jQuery. Those are the input boxes I have.
<html>
Quantity: <input type="text" style="width: 50px;" name="quantity" id="quantity" class="txt" value="1" />
Unit Price: <input type="text" style="width: 50px;" name="item_price" id="item_price" class="txt" value="" />
Amount: <input type="text" style="width: 50px;" name="total_price" id="total_price" class="txt" value="" />
</html>
Here I will show my jQuery code.Quantity ; price and Amount value also changes.jQuery Code, but unable to find the problem?
<script>
$('#quantity').click(function () {
var number = $(this).val();
var o_val = $("#unit_pricea").val();
var op_val = number * o_val;
$("#amounta").val(op_val);
console.log(op_val);
});
</script>
Here I will share my screen shots.
- First image whenever I enter unit price amount filed not fill:
- Second image unit price can I change previous value of amount not change:
- Quantity will be change amount not changed: