Fusion Manage Forum
Welcome to Autodesk’s Fusion Manage (formerly Fusion 360 Manage) Forum. Share your knowledge, ask questions, and explore popular Fusion Manage topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Number 1234567 to 1,234,567?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
702 Views, 3 Replies

Number 1234567 to 1,234,567?

This is more of a javascript question.  Does anyone have an easy way to convert a number like 1234567 to 1,234,567 format?  

 

I tried using toLocaleString() but it doesn't seem to work.  I then tried using a regex but couldn't make it work either.  I then thought about adding commas to every third digit using for loop before I stopped myself and reached out for help.

Tags (1)
3 REPLIES 3
Message 2 of 4
tony.mandatori
in reply to: Anonymous

There are a couple of ways of formatting numbers

 

You can use a computed field like this:

TO_CHAR(UGLY_FIELD, 'FM999,999,999,990D00')

 

Or

 

You can use script a a regular expression like this

item.NICE_FIELD = uglyField.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");

 

I tried both of these and they seem to work.

 

Message 3 of 4
Anonymous
in reply to: tony.mandatori

Ah.. Thanks toni. I had tried the regular expressions and had something similar. I'll give it a go in the morning. I like the computed one cause i don't have to mess around with the code. Thanks.

[http://www.nucap.com/images/image001.jpg] Jason Leung - Design Engineer
NUCAP Industries Inc.
3370 Pharmacy Avenue, Toronto ON
Ph.416 494 1444 FAX.416 494 2505
Jason.Leung@nucap.com

Please visit us at www.nucap.com www.gripmetal.com



[http://www.nucap.com/images/banner-nrx.png]
Message 4 of 4
Anonymous
in reply to: Anonymous

Tony,

 

This one worked nicely.  Thanks.

 

item.NICE_FIELD = uglyField.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report