Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to format number

Posted on 2002-04-26
3
Medium Priority
?
576 Views
Last Modified: 2008-02-01
How do you format a javascript number as 9,999,990.00 as in java
0
Comment
Question by:EdwardSee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Accepted Solution

by:
rajeev1972 earned 200 total points
ID: 6972893
Use this sample

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function addComma(numVar)
{
     var formattedNumber="";
     var commaNumber = "";
     var j = numVar.indexOf(".");

     if (j != -1)
     {
          for(i = numVar.length; i>j; i--)
          {    
               formattedNumber = formattedNumber + numVar.charAt(i-1);
          }
     }
     else
          j = numVar.length;

     for (i = j; i > 0; i--)
     {
          if ( (i != j) && ((j - i) % 3 == 0))
                 formattedNumber = formattedNumber + ",";
          formattedNumber = formattedNumber + numVar.charAt(i-1);
     }
     for (i = formattedNumber.length - 1; i >= 0; i--)
          commaNumber = commaNumber + formattedNumber.charAt(i);
     return commaNumber;
}

//-->
</SCRIPT>
</HEAD>

<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
alert(addComma("12312321.9800"));
//-->
</SCRIPT>
</BODY>
</HTML>
0
 
LVL 12

Expert Comment

by:ahosang
ID: 8131937
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

points to rajeev1972
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
ahosang
EE Cleanup Volunteer
0
 

Expert Comment

by:modulo
ID: 8191426
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question