Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To 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 March 15th, 2005, 11:11 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default Decimal Point

Hi all,

I am pulling values from an Excel file into a div. (thanks Joe Fawcett). Now, the next problem I have is that the values are percentages, and when they are displayed in the div, they are about 15 characters long and the decimal is in the wrong place. So instead of getting "95.04%", I am getting "0.9504034537733". Is there a function I can use to get rid of some of the numbers and move the decimal point along 2 places? I would be looking for something like this if it exists:

document.getElementById("divOutputA").innerText = oWS.Range("AF67").value.TrimNumbersAndMoveDecimalF unctionHere();

Once again TIA
interrupt



__________________
\'sync\' <cr>
The name specified is not recognized as an internal or external command, operable program or batch file.
 
Old March 16th, 2005, 01:11 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii Interrupt!!!
Try this link
http://developer.irt.org/script/1494.htm


Cheers :)

vinod
 
Old March 16th, 2005, 05:28 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Vinod,

Thanks for the link, but it seems quite a heavy way to do it. Plus I don't really understand the script that well. Can you think of a quicker way to do this? I don't really want to be writing that amount of script for every cell of data I pull in, and there's alot.

TIA
interrupt

 
Old March 16th, 2005, 05:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

maybe something simple like this will be good enough for you?
document.getElementById("divOutputA").innerText = Math.round(10000 * oWS.Range("AF67").value) / 100.0
 
Old March 16th, 2005, 05:53 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

pgtips, thats just the job.

Thanks very much!
interrupt





Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there any point RobReid Flash (all versions) 0 September 26th, 2008 09:07 AM
Replace decimal point with another value bonekrusher XSLT 8 March 5th, 2007 12:22 PM
decimal data type all 0's after decimal gobotsoup SQL Server ASP 1 February 28th, 2007 02:32 PM
Decimal point marcusbris Visual Basic 2005 Basics 3 January 18th, 2007 05:55 AM
How to control the decimal point precision johnsonlim026 ASP.NET 1.0 and 1.1 Basics 0 August 7th, 2005 11:58 PM





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