eva21 Posted December 2, 2008 Share Posted December 2, 2008 Im having a hard time getting it to do the right calculations. Here is my javascript code: //Checks to see if all the values have been inputted total = cost2 + travelCost2; cents = salary2/1920 * 76.5; dec = accCost2 * nightsAcc2; total2 = total + cents + dec; //total2 = total2.toFixed(2); //put it back into the total document.getElementById("totalCost").value = "$" + total2; Except in the total box, it gives me total, cents, and dec into a string like for example Total | 10.000.420 Why is it doing that instead of adding the three things together? Link to comment https://forums.phpfreaks.com/topic/135161-doing-calculations-in-javascript/ Share on other sites More sharing options...
eva21 Posted December 2, 2008 Author Share Posted December 2, 2008 Firgured it out Link to comment https://forums.phpfreaks.com/topic/135161-doing-calculations-in-javascript/#findComment-703985 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.