473,395 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

help with .toFixed(2)

Basically Im using parsefloat to help add a certain amount to a variable passed on from another page, but now instead of it appearing as 45.50, it appears as 45.5.
Expand|Select|Wrap|Line Numbers
  1. var pay=50,res;
  2.  
  3.      document.getElementById("3").innerHTML = p[1];
  4.      document.getElementById("77").innerHTML = p[1];
  5.      document.getElementById('77').value = document.getElementById('3').innerHTML;
  6.      document.getElementById('4').value = document.getElementById('77').innerHTML;
  7.      document.getElementById('5').value = document.getElementById('77').innerHTML;
  8.  
  9.  
  10.      document.getElementById("3").innerHTML = p[1].replace('+', ' ').replace('%C2%A3', '£').replace(' UK', ' ');
  11.      document.getElementById("77").innerHTML = p[1].replace('+', ' ').replace('%C2%A3', '£').replace(' UK', ' ');
  12.      document.getElementById("4").innerHTML = parseFloat(p[1]) + 5;
  13.      res = parseFloat(p[1])*( pay / 100);
  14.      document.getElementById("5").innerHTML = parseFloat(p[1]) + res;
Basically I need to have "5" and "4" to be displayed to 2 decimal places. Ive tried using toFixed(2) but i cant seem to get it to work.
Also before anyone mentions, I know the site fails to function as it should on google chrome and some other browsers and Im working on that :)
Feb 3 '10 #1
3 2876
Dormilich
8,658 Expert Mod 8TB
worked when I tried toFixed().
Feb 3 '10 #2
Where would I put to.fixed though?
Thanks
Feb 8 '10 #3
Dormilich
8,658 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. (parseFloat(p[1]) + res).toFixed(2);
Feb 8 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: ajordan | last post by:
hello! i think i have a bug when i use parseFoat function: i have the following operation : parseFloat("10.664062") + parseFloat("10.664062") +parseFloat("10.664062"); the result of...
6
by: Brian | last post by:
Help.. We cannot get this script to work..can someone take a look at it and make suggestions? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Convert...
12
by: BC | last post by:
I have read the FAQ and the discussions but I am not a Javascript programmer and do not know how to make toFixed (and other techniques) work, after several attempts. The following calculations...
4
by: Adrienne | last post by:
I am the first to admit that I know bupkis about javascript, except that sometimes I need it to do something client side that I can't do server side. Anyway, here's my problem: <input...
17
by: Phil McKraken | last post by:
I am having a problem putting together a shopping cart with the below script. Everything displays fine, adds totals fine, and works perfect EXCEPT if you choose the 9.95 item #5 BY ITSELF the total...
5
by: thehonos | last post by:
I am trying to help a former student. He needs to resolve this problem in javascript and I do not teach javacript and I am lost.. Can any one help?!?!?!? Write JavaScript to solve the following...
1
by: VK | last post by:
Anyone could tell what result is displayed for alert(1.035.toFixed(2)) on Safari 2.0.4 ?
11
by: Dirntknow | last post by:
Further to my recent post in this newsgroup i've got to admit i'm struggling. I've no experience with javascript or it's workings. What i'd like is a simple converter to allow a user to input the...
2
by: CptDondo | last post by:
I'm not that familiar with javascript, and I am trying to write a toFixed function. The function takes two arguments, the number and the number of decimal places we're interested in. If the...
3
by: brossyg | last post by:
I have a function that calculates price when the user inputs a quantity that works perfectly. Here it is: function STWCORPrice() { var price = 0; var shipping = 0; var total=0; var...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.