Jump to content

Doing calculations in javascript.


eva21

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.