Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 28th, 2005, 09:01 AM
Friend of Wrox
 
Join Date: Mar 2004
Location: Ottawa, , Canada.
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default percentage

Hi,

Through my math function, I'm getting a percentage.. but how do you format it? I'm getting 1.5151515151515151% when I would like to have 1%...

var percent = done/total*100;
document.getElementById('Percent').innerHTML = percent + "%";

Reply With Quote
  #2 (permalink)  
Old October 28th, 2005, 09:08 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Use the floor() method.

HTH!

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
Reply With Quote
  #3 (permalink)  
Old October 28th, 2005, 03:55 PM
Friend of Wrox
 
Join Date: Mar 2004
Location: Ottawa, , Canada.
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanx, but I found toFixed(0), and that seems to be working.. and as they say if it's not broke... don't fix it... but thank you anyways...

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculate Percentage with Date mateenmohd Access 2 February 4th, 2008 06:26 AM
Percentage: IE6 vs. All others? tal HTML Code Clinic 3 August 1st, 2007 06:57 PM
percentage height GuyB CSS Cascading Style Sheets 1 July 6th, 2006 10:42 PM
Height/position specified as percentage GuyB ASP.NET 2.0 Basics 0 July 3rd, 2006 08:13 PM
Calculate a difference percentage skwilliams Classic ASP Basics 15 April 4th, 2006 07:46 AM



All times are GMT -4. The time now is 04:25 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.