p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Javascript How-To (http://p2p.wrox.com/forumdisplay.php?f=87)
-   -   Decimal Point (http://p2p.wrox.com/showthread.php?t=26871)

interrupt March 15th, 2005 11:11 AM

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




vinod_yadav1919 March 16th, 2005 01:11 AM

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


Cheers :)

vinod

interrupt March 16th, 2005 05:28 AM

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


pgtips March 16th, 2005 05:45 AM

maybe something simple like this will be good enough for you?
document.getElementById("divOutputA").innerText = Math.round(10000 * oWS.Range("AF67").value) / 100.0

interrupt March 16th, 2005 05:53 AM

pgtips, thats just the job.

Thanks very much!
interrupt



All times are GMT -4. The time now is 08:52 PM.

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