javascript - jQuery - Simple math returning NaN -
i trying simple math, using below function. function called onchange
:
var exposure = $('#exposure').find(":selected").val(); var budget = $('.budget').val(); var ppc = $('.ppc').val(); var value = budget/ppc; var total2 = math.floor(value*0.95); if(exposure == 2){ var dref = 0.0005; }else if(exposure == 3){ var dref = 0.005; }else if(exposure == 4){ var dref = 0.001; } if(exposure > 1){ var add = dref+ppc; var value2 = budget/add; var total2 = math.floor(value2*0.95); } $("#sum").text("" + total2 + " clicks");
my problem is, if exposure > 1
, total2
value in #sum
return nan
what doing wrong?
do parseint(value,10)
intergers or parsefloat(value)
float.
javascript appends values if data type not number.
like:
budget = parseint(budget,10);
Comments
Post a Comment