Here is the function function showPrice2(items,def, lp){ if (items != 0){ ss = document.form2.color.options[form2.color.selectedIndex].value; if(undefined===window.ss){ window.ss = '0,0'; } if(items == '0,0,0,0'){ var valArray = new Array(); valArray[0] = 0; valArray[1] = def; valArray[2] = lp; valArray[3] = 0; } else{ var strValue=new String(items); var valArray = strValue.split(","); } var clr=new String(ss); var clrarr = clr.split(","); clrs = parseFloat(clrarr[1]); endprice = Number(valArray[1]) + Number(clrs); alert(endprice); //............ some more code. I am getting error in above line. HTML: Number(clrs) is creating problem. When I pass zero (0) to it result is fine. When I pass 5.00 to it I get NaN in alert. Can somebody help me why I am getting NaN error.
I have also tried 5. I have tried every way to convert string into integer but everytime I am getting NaN. I am doing typecasting here still NaN ??? I have tried pasreFloat I have tried var a = 1*clrs Nothing worked for me.
Well your setting clrs to a float, so maybe that is the problem? I can't test now so I'm not sure, I can't test it right now. Actually, I would print out the values of ss, clr, and clrs to ensure it's actually parsing into something that will convert into a number. I bet it's creating a string that can't properly convert to a number using the number function, perhaps there is a space or something.