Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | 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 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 Search this Thread Display Modes
  #1 (permalink)  
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.
Reply With Quote
  #2 (permalink)  
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
Reply With Quote
  #3 (permalink)  
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

Reply With Quote
  #4 (permalink)  
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
Reply With Quote
  #5 (permalink)  
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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
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



All times are GMT -4. The time now is 03:41 AM.


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