Avatar of parajrn

asked on 

NaN Error in Subtotal Field

Hi everyone,

I'm writing because I've been working to code a fairly simple order form and while I've pretty much gotten everything down, I'm having an issue with getting NaN errors if the discount field on the form does not contain a value.

For example, the form starts out with 0 in the field, and if a user changes the value, the amount is deducted from the total, however if a user erases the 0 or value and leaves the field blank, the subtotal column will display an NaN error.

I've tried sorting through the code and putting in code to treat the discount field as 0 if it is NaN however no matter what I try I haven't been able to solve the issue.

I've attached the code, however it is fairly lengthy mainly due to the fact that the item listings are repeated ten times. The main code to focus on is really at the top near the head (in the script field) and probably the lines after the last item listing where you see Sales Tax and such.

Also, the current version of the form is at:  http://intensivejournal.org/info/buyItems.php

Thanks very much in advance for any assistance.
Web DevelopmentJavaScript

Avatar of undefined
Last Comment

8/22/2022 - Mon