I have a function in jquery. my function returns a value but when i checked the returned value, I got a ‘NAN’ what could be the problem:
[CODE]
var vax = ('#textbox1').val();
var newVal = calculateMB(vax,11,3.1);
alert(newVal);
function calculateMB(num,charge,fixed)
{
if(num>50)
var e = num - 50;
var new_e = e * charge;
new_var = new_e / 20;
return (new_var + fixed);
}
[/CODE]
I think it is because the number being read from the text box is a string. Try
var vax = Number(('#textbox1').val());