PDA

View Full Version : Issue in Displaying NaN values



newphpbees
07 Mar 2012, 04:16 AM
Hi..

I created a function and I encountered problem because I got a NaN values. And I want to resolve it..I don't want to display NaN values. instead of NaN I just want it blank.

here is my code:


function doz(oText){
var P27_max = document.getElementById("P27_max").value;
var P27_max_convert = parseFloat(P27_max) + parseFloat(1);
var P27_maxdoz = document.getElementById("P27_maxdoz").value = P27_max_convert;


var P28_max = document.getElementById("P28_max").value;
var P28_max_convert = parseFloat(P28_max) + parseFloat(2);
var P28_maxdoz = document.getElementById("P28_maxdoz").value = P28_max_convert;
}


when I entered data in
P27_max so the P27_maxdoz was computed but the problem is the P28_max has also value 'NaN'.

How can I eliminate or did not display NaN

Thank you

Kirsteins
13 Apr 2012, 12:54 AM
You can check it with isNaN() function http://www.w3schools.com/jsref/jsref_isnan.asp