0
var pricePerItemExVat = parseInt($("#ConsumerWSP").val()) / parseInt($("#ConsumerItemSellUnit").val());
var pricePerItemIncVat = pricePerItemExVat + (pricePerItemExVat * parseInt($("#pricingConsumerVat").text()));
var consumerPor = ((parseInt($("#itemRRP").val()) - pricePerItemIncVat) / parseInt($("#itemRRP").val())) * 100;
alert(consumerPor);

Even when all my fields have values(and also values greater than ZERO) the alert returns me a NaN.

Why Is it so ?

How may I do this calculation in javascript ?

Sully
  • 14,672
  • 5
  • 54
  • 79
Nishant Rambhojun
  • 77
  • 1
  • 2
  • 10

1 Answers1

0

You have get the text in-place of value. As per code you are trying to pricePerItemExVat divide by Empty. So pricePerItemIncVat value is "NaN".

$("#pricingConsumerVat").text()));

enter image description here

Let me know if any concern.

Edit 1:

var pricePerItemExVat = parseInt($("#ConsumerWSP").val()) / parseInt($("#ConsumerItemSellUnit").val());
alert(pricePerItemExVat );
var pricePerItemIncVat = pricePerItemExVat + (pricePerItemExVat * parseInt($("#pricingConsumerVat").val()));
alert(pricePerItemIncVat );
var consumerPor = ((parseInt($("#itemRRP").val()) - pricePerItemIncVat) / parseInt($("#itemRRP").val())) * 100;
alert(consumerPor);
Jayesh Goyani
  • 11,008
  • 11
  • 30
  • 50