{"id":12870728,"date":"2020-05-21T14:53:14","date_gmt":"2020-05-21T14:53:14","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/vars-are-not-adding-correctly\/"},"modified":"2020-05-21T14:53:14","modified_gmt":"2020-05-21T14:53:14","slug":"vars-are-not-adding-correctly","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/vars-are-not-adding-correctly\/","title":{"rendered":"Vars are not adding correctly"},"content":{"rendered":"<p>I&#8217;m building a calculator for but the totals are not displaying correctly. I have formulas setup for the fields and then they are populated into an html section.<br \/>\nAll of the calculations work correctly except for the total.<br \/>\nInstead of adding the two Var amounts, it&#8217;s placing them next to each other instead. <\/p>\n<p>Below is the code for the calculation function. The totalmins, totalhrs, etc. are the calculations that give the incorrect amount.<\/p>\n<p>Is there a way to get those calculations to display correctly within the HTML?<br \/>\nThanks!<\/p>\n<pre><code>(function(){\nvar annual = (fieldname19*(fieldname13\/100)),\nrevlostweek = (annual\/52),\nrevlostweek1 = (PREC(revlostweek,2)),\nrevlostday = (PREC(annual\/365,2)),\nrevlosthour = (PREC(annual\/8760,2)),\nrevlostmin = (PREC(annual\/525600,2)),\nproductivity = (fieldname20\/100),\nprodlosthour1 = ((fieldname3*fieldname11)*productivity),\nprodlosthour2 = (PREC(prodlosthour1*1,2)),\nprodlostmin = (PREC(prodlosthour2\/60,2)),\nprodlostday = (PREC(prodlosthour2*24,2)),\nprodlostweek = (PREC(prodlosthour2*168,2)),\ntotalmins = (revlostmin+prodlostmin),\ntotalhrs1 = (PREC(revlosthour+prodlosthour2,2)),\ntotalday1 = ((revlostday)+(prodlostday)),\ntotalweek1 = (revlostweek + prodlostweek);\n\njQuery(&#039;.revlost_week&#039;).html(revlostweek);\njQuery(&#039;.revlost_day&#039;).html(revlostday);\njQuery(&#039;.revlost_hour&#039;).html(revlosthour);\njQuery(&#039;.revlost_min&#039;).html(revlostmin);\njQuery(&#039;.prodlost_hour&#039;).html(prodlosthour2);\njQuery(&#039;.prodlost_min&#039;).html(prodlostmin);\njQuery(&#039;.prodlost_day&#039;).html(prodlostday);\njQuery(&#039;.prodlost_week&#039;).html(prodlostweek);\njQuery(&#039;.total_mins&#039;).html(totalmins);\njQuery(&#039;.total_hours&#039;).html(totalhrs1);\njQuery(&#039;.total_days&#039;).html(totalday1);\njQuery(&#039;.total_week&#039;).html(totalweek1);\n})()<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-12870728","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12870728","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12870728\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=12870728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}