Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# jQuery/Javscript math calculation not working

Posted on 2011-09-04
Medium Priority
350 Views
On this screen:

https://www.interactivehealthpartner.com/mfc_goals.asp

Click Weight Management, enter some pounds to lose and click "calculate now". For the first box on the right, Daily calorie reduction need to accomplish your goal, this is the equation:

Daily_calorie_reduction = total_number_of_days_in_goal_period / (pounds_to_lose*3500)

The part of my code which accomplishes this is attached, but I keep getting NaN. Is there something obvious I am doing which won't allow this to calculate? Thank you!
``````var weight2aStartDate=Date.parseExact(\$('#startdate option:selected').val(), 'M/d/yyyy');
var weight2aBegin=Date.parseExact(\$('#startdate option:selected').val(), 'M/d/yyyy');
var weight2aTerm=parseInt(\$('#term').val());
var weight2a=parseInt(days_between(weight2aBegin, weight2aEnd))/(parseInt(\$('#weight1b'))*3500);
``````
0
Question by:bbdesign
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 82

Accepted Solution

leakim971 earned 2000 total points
ID: 36480518
replace line 5 :
var weight2a=parseInt(days_between(weight2aBegin, weight2aEnd))/(parseInt(\$('#weight1b'))*3500);
by :
var weight2a=parseInt(days_between(weight2aBegin, weight2aEnd))/(parseInt(\$('#weight1b').val())*3500);
0

Author Comment

ID: 36481040
Of course, I missed the val(). Thank you.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be \$37.1B.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
###### Suggested Courses
Course of the Month8 days, 18 hours left to enroll