![]() |
![]() |
![]() | #1 | |
Çevrimdışı ![]() IF Ticaret Sayısı: (0) | javascript sayıları formatlamak /** * * * * örnek uygulamalar: * format(12345.6789); //12345,67 * format(12345.6789, {point:'.'}); //12345.67 * format(12345.6789,{suffix:'€'}); //12345,67€ * format(12345.6789,{point:'.',prefix:'$ '}); //$ 12345.67 */ var format = function(num, options)) { options.point=options.point||','; options.group=options.group||' '; options.places=options.places||2; options.suffix=options.suffix||''; options.prefix=options.prefix||''; regex = /(\d+)(\d{3})/; result = ((isNaN(num) ? 0 : Math.abs(num)).toFixed(options.places)) + ''; for (result = result.replace('.', options.point); regex.test(result) && options.group; result=result.replace(regex, '$1'+options.group+'$2')) {}; return (num < 0 ? '-' : '') + options.prefix + result + options.suffix; };
__________________ | |
| ![]() |
![]() |
Etiketler |
formatlamak, javascript, sayıları |
Konuyu Toplam 1 Üye okuyor. (0 Kayıtlı üye ve 1 Misafir) | |
| |
![]() | ||||
Konu | Konuyu Başlatan | Forum | Cevaplar | Son Mesaj |
php web adreslerini formatlamak | hAte | PHP | 0 | 08 Ekim 2014 08:27 |
"Öğrenci formatlamak bizim hedefimiz değildir!". | Neo | Haber Arşivi | 0 | 06 Şubat 2012 16:15 |
Aşk'ın Sayıları | Hasan | Burçlar, Fallar ve Kehanetler | 9 | 19 Ağustos 2006 21:02 |