newphpcoder Posted March 7, 2012 Share Posted March 7, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/258448-issue-in-displaying-nan-values/ Share on other sites More sharing options...
trq Posted March 7, 2012 Share Posted March 7, 2012 https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/isNaN Quote Link to comment https://forums.phpfreaks.com/topic/258448-issue-in-displaying-nan-values/#findComment-1324811 Share on other sites More sharing options...
newphpcoder Posted March 8, 2012 Author Share Posted March 8, 2012 I resolved it using this code: var P45_min = document.getElementById("P45_min").value; var P45_min_convert = parseFloat(P45_min) + parseFloat(13); if( !isNaN(P45_min_convert) ){ var P45_mindoz = document.getElementById("P45_mindoz").value = P45_min_convert; } Thank you Quote Link to comment https://forums.phpfreaks.com/topic/258448-issue-in-displaying-nan-values/#findComment-1325030 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.