A
A
AndyLarcin2014-11-21 11:29:26
JavaScript
AndyLarcin, 2014-11-21 11:29:26

ParseFloat correct work?

Essence of the question:
var extra_fee_code=parseFloat(ans['extra_fee_code']);
var extra_fee_subcode=parseFloat(ans['extra_fee_subcode']);
var extra_fee_payable=parseFloat(ans['extra_fee_payable']);
As a result, it produces NaN how to fix it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Sydorenko, 2014-11-21
@AndyLarcin

It's hard to guess what exactly you have in ans .. But maybe so?

var extra_fee_code=parseFloat(ans.extra_fee_code);
var extra_fee_subcode=parseFloat(ans.extra_fee_subcode);
var extra_fee_payable=parseFloat(ans.extra_fee_payable);

But most likely you do not correctly form (send) ans (from php). Put a breakpoint in your JS code before the first call to parseFloat, and look in the inspector to see what's really in ans.

D
Denis Ineshin, 2014-11-21
@IonDen

NaN appears when you try to convert something into a number that can't be converted. For example: undefined, "", "string", etc.
Check what's in those variables initially.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question