Default TemplateGreen TemplateBlue TemplateRed TemplateGold TemplateBlue Gloss Template
Article Categories

Mycities Network
Java Scripts Examples and Tutorials
Number formating in Java Scripts (d commas)

Saturday Oct 14, 2006
This functionality is not built into JavaScript, so custom code needs to be used. The following is one way of adding commas to a number, and returning a string.

function eInterNextaddCommas(nStr)
{
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}



Comments : What do you think about this news?
No Comments yet.

POST COMMENT
Name
Message
  Post will be visible after admins approval
 

About Maldives Resorts

Members Login
User ID
Password
    Register
Forgot password?

SriLankaWebHosting.com
Just for (Rs.500) $5 per month

Your own domain name, 1GB Space, Unlimited Email Address, Sri Lankan Support & for more info call us.
077-989-5368, 072-829-9077



Terms And Conditions | Link Directory

Join Sri Lanka Banner Exchange | Resources - Free Link Exchange