you need to convert values to int
.
do like this:
$("#retailer_commission").on('keyup',function(){
var total = parseInt($("#price_exc_vat").val())/100;
total = total*parseInt($(this).val());
$("#retailer_cog").val(total);
});
Question
I have the following 3 fields in a form. I need to generate the result into the retailer_cog fiueld after entering the second value in retailer_commission. The calculation is (price_exec_vat * retailer_commission)
AS The commission is a percentage IS USE THE FOLLOWING ACTUAL CALCULATION ((price_exc_vat/100)*retailer_commission)
<input name="price_exc_vat" type="number" id="price_exc_vat" placeholder="0.00" min="0" step="0.01" >
<input name="retailer_commission" type="number" id="retailer_commission" placeholder="0" min="0" step="1" >
<input name="retailer_cog" id="retailer_cog" type="text" readonly>
Solution
you need to convert values to int
.
do like this:
$("#retailer_commission").on('keyup',function(){
var total = parseInt($("#price_exc_vat").val())/100;
total = total*parseInt($(this).val());
$("#retailer_cog").val(total);
});
OTHER TIPS
try this
use the value of qty and set the total using id retailer_cog
var qty=$("#retailer_commission");
qty.keyup(function(){
var total = ($("#price_exc_vat").val()/100);
total = (total*qty.val());
$("#retailer_cog").val(total);
});
total = ($("#price_exc_vat").val()/100);
total = (total*qty.val()); //changes in this line
$("#retailer_cog").val(total);
});