Click to See Complete Forum and Search --> : Need help! NaN appearing
beckg
08-17-2003, 01:07 PM
I have a form located at http://www.whitewhistlewedding.com/cwl_dev/neworderform.php (right-click disabled, use view source). When items are selected, NaN appear in the subtotal and payment fields. I am not novice with this type of script. Can anyone take a look and help me correct this?
Khalid Ali
08-17-2003, 01:25 PM
one or more fields are trying to perform a calculation on a string which can not be converted to a numbr..make sure all vcalues are numbers that are required for calcs..
Most of your functions are calling calculate() before any values have been entered.
See onchange=ribbon_hat_lst(this), it's an option change, but still calls calculate() ... and others.
beckg
08-17-2003, 01:58 PM
well, I didn't write this script. It was originally written by one programmer, and then another. I checked the values and they are at 0. I don't know about the functions because I really do not know about JavaScript and especially about the math functions.
If the values are 0 and you do a calculation using 0 the answer is likely to be NaN.
Not all the functions need to call calculate() - see previous reply(s).
beckg
08-17-2003, 02:10 PM
if(isEmpty(y.value)) { in line 63. I understand about the value and the calculations using a 0. Am I to take 0 out of all values?
Khalid Ali
08-17-2003, 02:20 PM
NaN = Not a Number
is thrown when you try to parse a string that can not be converted to a number.
A field having 0 value should not cuase this only,You will need to make sure that there is not string that is being used in a calculation...all values must be converted to a number then used in calculation
pillow_emb_total appears twice - line 1461
<INPUT disabled size=5 value=0 name=pillow_emb_total><INPUT type=hidden name=pillow_emb_total>
I took out the <OBJECT> tag to test your script and the NaN problem disappears!
beckg
08-17-2003, 03:29 PM
do you mean the flash object tag? I took that out and I still have the same problems. can you send me the code that worked for you so I can compare what I have to what you have? I deleted the duplicate tag. I get the NaN when I also begin filling in the form. When the Client state is chosen, subtotal and the rest go to NaN. thanks for your help btw...to everyone that has replied.
I would first suggest you run your page through the following validators:
HTML (http://validator.w3.org/)
CSS (http://www.htmlhelp.com/tools/csscheck/)
JavaScript (http://www.crockford.com/javascript/jslint.html)
The HTML validator reported 157 errors!
The CSS file is possibly loaded twice (lines 4 and 650)
Turn off the timer and remove the flash object (that is all I did) before continuing with debugging.