Advertisement

09.26.2008 at 02:29AM PDT, ID: 23765507 | Points: 500
[x]
Attachment Details

how do i format a number as a european currency?

Asked by markmchugh in JavaScript

Tags:

Hi,
How do i format a number as a currency? When i pass this function the number 54.45 it retuens 540.45

here is it

function formatNumber(number)
{
       
            var nStr = '' + Math.round(parseFloat(number) * 100) / 100;
        var x = nStr.split('.');
        var x1 = x[0];
        var x2 = x.length > 1 ? '.' + x[1] : '';
        x2 = parseFloat(x2).toFixed(2);
        var rgx = /(\d+)(\d{3})/;

        while (rgx.test(x1)) {
                x1 = x1.replace(rgx, '$1' + ',' + '$2');
        }       
            
        return x1 + x2;
}Start Free Trial
 
Loading Advertisement...
 
[+][-]09.26.2008 at 02:50AM PDT, ID: 22577899

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.26.2008 at 02:51AM PDT, ID: 22577907

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.26.2008 at 02:54AM PDT, ID: 22577922

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.26.2008 at 03:23AM PDT, ID: 22578034

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.26.2008 at 03:51AM PDT, ID: 22578179

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.26.2008 at 05:55AM PDT, ID: 22578926

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.27.2008 at 01:07AM PDT, ID: 22585912

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43 / EE_QW_2_20070628