[jQuery] Re: how to change 2,5 to 2,50 ?

2009-07-08 Thread Massimo Lombardo
Yeah, that's what I mean ;) That's why I explicitly cited IEEE754 in my reply instead of saying something like «heh, you know, it's that weird javascript thing with numbers» :) On Wed, Jul 8, 2009 at 04:53, RobGrobg...@gmail.com wrote: On Jul 7, 9:14 pm, Massimo Lombardo

[jQuery] Re: how to change 2,5 to 2,50 ?

2009-07-07 Thread weidc
solved it by myself. endpreis =Math.round(endpreis*100)/100; endpreis = endpreis+ foo; endpreis = endpreis.replace(/ foo/,); var cent = endpreis.split(.); if(cent[1].length == 1) { endpreis = endpreis+0; }else{ if(cent[1].length == 2) { //schoen so

[jQuery] Re: how to change 2,5 to 2,50 ?

2009-07-07 Thread jeff
ha ha good work :) On Tue, Jul 7, 2009 at 4:29 PM, weidc mueller.juli...@googlemail.comwrote: solved it by myself. endpreis =Math.round(endpreis*100)/100; endpreis = endpreis+ foo; endpreis = endpreis.replace(/ foo/,); var cent = endpreis.split(.); if(cent[1].length == 1) {

[jQuery] Re: how to change 2,5 to 2,50 ?

2009-07-07 Thread Massimo Lombardo
This one is more general (and faster, I think: no if-else, no regexp) Number.prototype.padRight = function (fill) { var v = this.toString().split('.'), d = v[1] || ''; return (v[0] || '0') + '.' + d + fill.substr(d.length); } test1 = 2; test2 = 3.141592; test3 = 0.001; test4 = .33;

[jQuery] Re: how to change 2,5 to 2,50 ?

2009-07-07 Thread weidc
no it's not for money + - money. it's just to show the price of something - % action in different sizes after selecting something in dropdown options. everything else is with php of course. but i'll try your way too. :) On 7 Jul., 13:14, Massimo Lombardo unwiredbr...@gmail.com wrote: This one

[jQuery] Re: how to change 2,5 to 2,50 ?

2009-07-07 Thread Giovanni Battista Lenoci
weidc ha scritto: no it's not for money + - money. it's just to show the price of something - % action in different sizes after selecting something in dropdown options. everything else is with php of course. but i'll try your way too. :) As a (mainly) php programmer I think this site is

[jQuery] Re: how to change 2,5 to 2,50 ?

2009-07-07 Thread weidc
the price have to change on the page without reloading the site. the javascript is just to look well for the customers. but thank you anyway! On 7 Jul., 13:24, Giovanni Battista Lenoci gian...@gmail.com wrote: weidc ha scritto: no it's not for money + - money. it's just to show the price of

[jQuery] Re: how to change 2,5 to 2,50 ?

2009-07-07 Thread RobG
On Jul 7, 8:11 pm, weidc mueller.juli...@googlemail.com wrote: hi, thats my code: endpreis =Math.round(endpreis*100)/100; to round the price of something but i'd like to have 2,00 or 2,50 instead of 2 and 2,5. i'd be happy about any help. To format a number in javascript with exactly

[jQuery] Re: how to change 2,5 to 2,50 ?

2009-07-07 Thread Giovanni Battista Lenoci
weidc ha scritto: the price have to change on the page without reloading the site. the javascript is just to look well for the customers. but thank you anyway! Yes, the functions I've posted are javascript trasposition of php functions. In php exists the number format function: |$number =

[jQuery] Re: how to change 2,5 to 2,50 ?

2009-07-07 Thread Cesar Sanz
@googlegroups.com Sent: Tuesday, July 07, 2009 7:30 AM Subject: [jQuery] Re: how to change 2,5 to 2,50 ? weidc ha scritto: the price have to change on the page without reloading the site. the javascript is just to look well for the customers. but thank you anyway! Yes, the functions I've posted

[jQuery] Re: how to change 2,5 to 2,50 ?

2009-07-07 Thread Massimo Lombardo
Thank you :) On Tue, Jul 7, 2009 at 16:46, Cesar Sanzthe.email.tr...@gmail.com wrote: Massimos' Number.prototype.padRight = function (fill) {   var v = this.toString().split('.'), d = v[1] || '';   return (v[0] || '0') + '.' + d + fill.substr(d.length); } Very elegant solution!! --

[jQuery] Re: how to change 2,5 to 2,50 ?

2009-07-07 Thread mkmanning
There are also some currency formatting plugins: http://plugins.jquery.com/project/currencyFormat (or search currency under plugins) On Jul 7, 3:11 am, weidc mueller.juli...@googlemail.com wrote: hi, thats my code: endpreis =Math.round(endpreis*100)/100; to round the price of something

[jQuery] Re: how to change 2,5 to 2,50 ?

2009-07-07 Thread RobG
On Jul 8, 1:59 am, mkmanning michaell...@gmail.com wrote: There are also some currency formatting plugins: http://plugins.jquery.com/project/currencyFormat That appears to make extensive use of toFixed(), which is known to be buggy in some browsers for certain values. Try: alert(

[jQuery] Re: how to change 2,5 to 2,50 ?

2009-07-07 Thread RobG
On Jul 7, 9:14 pm, Massimo Lombardo unwiredbr...@gmail.com wrote: [...] As I see you're dealing with cents, money and stuff, I have to remember you that JavaScript use IEEE 754 Floating Points as its own internal number type, so 0.1 + 0.2 !== 0.3: people tend to be very picky when dealing