Wrox Programmer Forums
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 28th, 2005, 08:01 AM
Friend of Wrox
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default percentage


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 + "%";

Old October 28th, 2005, 08:08 AM
richard.york's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts

Use the floor() method.



Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
Old October 28th, 2005, 02:55 PM
Friend of Wrox
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts

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...

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 05:57 PM
percentage height GuyB CSS Cascading Style Sheets 1 July 6th, 2006 09:42 PM
Height/position specified as percentage GuyB ASP.NET 2.0 Basics 0 July 3rd, 2006 07:13 PM
Calculate a difference percentage skwilliams Classic ASP Basics 15 April 4th, 2006 06:46 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.