[jQuery] Re: format number

2009-10-06 Thread Jonathan Sharp
Doh...thank you Karl for saving my behind. Parse Int won't work...coffee
hadn't kicked in yet.
Cheers,
- Jonathan

On Mon, Oct 5, 2009 at 6:58 PM, Karl Swedberg  wrote:

>
> On Oct 5, 2009, at 11:43 AM, Jonathan Sharp wrote:
>
> You can run a parseint on the number: var myInt = parseInt( '15,000', 10);
> Cheers,
> - Jonathan
>
> http://jqueryminute.com
>
>
> Oops. that's not such a good idea. It'll return 15. ;-)
>
> There are probably much better ways of doing this, but one way is to use a
> regex replace:
> var someFormattedNumber = '15,000';
> +someFormattedNumber.replace(/\D/g,'')
>
>
> --Karl
>
> 
> Karl Swedberg
> www.englishrules.com
> www.learningjquery.com
>
>


[jQuery] Re: format number

2009-10-05 Thread Karl Swedberg


On Oct 5, 2009, at 11:43 AM, Jonathan Sharp wrote:

You can run a parseint on the number: var myInt =  
parseInt( '15,000', 10);


Cheers,
- Jonathan

http://jqueryminute.com



Oops. that's not such a good idea. It'll return 15. ;-)

There are probably much better ways of doing this, but one way is to  
use a regex replace:

var someFormattedNumber = '15,000';
+someFormattedNumber.replace(/\D/g,'')


--Karl


Karl Swedberg
www.englishrules.com
www.learningjquery.com



[jQuery] Re: format number

2009-10-05 Thread Jonathan Sharp
You can run a parseint on the number: var myInt = parseInt( '15,000', 10);
Cheers,
- Jonathan

http://jqueryminute.com


On Sun, Oct 4, 2009 at 7:49 AM, runrunforest  wrote:

>
> cool, but that leads to another problem
>
> The computer now thinks 15,000 is just 15 instead of fifteen thousands


[jQuery] Re: format number

2009-10-05 Thread RobG



On Oct 5, 12:13 am, Donny Kurnia  wrote:
[...]
> 15,000 should only displayed to user. You should keep 15000 somewhere in
> the document. My favorite is using alt
>
> 15,000

alt is not a valid attribute for span elements.


--
Rob


[jQuery] Re: format number

2009-10-04 Thread Donny Kurnia


runrunforest wrote:

cool, but that leads to another problem

The computer now thinks 15,000 is just 15 instead of fifteen
thousands. I need the formated number for later calculation, I have to
make the computer think 15,000 is actually fifteen thousands

Is there anyway to take the comma out before calculation or a function
that can tell 15,000 is 15000 in my case



15,000 should only displayed to user. You should keep 15000 somewhere in 
the document. My favorite is using alt


15,000

Please separate between display and data for process. Data for process 
should be kept in it's original data type. That data can be displayed in 
any forms, any text, any format.


--
Donny Kurnia
http://blog.abifathir.com
http://hantulab.blogspot.com
http://www.plurk.com/user/donnykurnia


[jQuery] Re: format number

2009-10-04 Thread runrunforest

cool, but that leads to another problem

The computer now thinks 15,000 is just 15 instead of fifteen
thousands. I need the formated number for later calculation, I have to
make the computer think 15,000 is actually fifteen thousands

Is there anyway to take the comma out before calculation or a function
that can tell 15,000 is 15000 in my case


[jQuery] Re: format number

2009-10-04 Thread runrunforest

cool, but that leads to another problem

The computer now thinks 15,000 is just 15 instead of fifteen thousands


[jQuery] Re: format number

2009-10-04 Thread Donny Kurnia


runrunforest wrote:


How can i make 1500 look like 15,000,000

and 1500.00 look like 15,000,000.00 ?



You can use this:
http://phpjs.org/functions/number_format:481

--
Donny Kurnia
http://blog.abifathir.com
http://hantulab.blogspot.com
http://www.plurk.com/user/donnykurnia


[jQuery] Re: Format number with pattern

2008-10-31 Thread MorningZ

Theres tons of Javascript solutions

http://www.google.com/search?q=javascript+format+number&ie=utf-8&oe=utf-8&aq=t

(which jQuery would do under the hood anyways)



On Oct 31, 4:21 pm, ipazmino <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I need to format a number as specified in a input pattern, Something like
> this:
>
> $("money").format("###.###,##");
> $("pi").format("#,#*");
>
> so, money will allow something like 2.500,75
> and pi wil allow something like 3.1416
>
> If you know a plugin that could work this way or similar, please let me
> know.
>
> Thanks in advance,
>
> IP
> --
> View this message in 
> context:http://www.nabble.com/Format-number-with-pattern-tp20238216s27240p202...
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.