Modifies a number by adding commas after every third digit. For example, 123456789 is converted to 123,456,789. The script example shows this script as used on numbers of various sizes.
Add the below code to the <body> section of your page:
<scriptlanguage="javascript"type="text/javascript"> /* Visit http://www.yaldex.com/
for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin function
Comma(number){ number =''+
number; if(number.length>3){ var
mod =
number.length%3; var
output =(mod
>0?(number.substring(0,mod)):''); for(i=0;
i <Math.floor(number.length/3);
i++){ if((mod
==0)&&(i
==0)) output +=
number.substring(mod+3*
i,
mod +3*
i +3); else output+=','+
number.substring(mod
+3*
i,
mod +3*
i +3);
} return(output);
} elsereturn
number;
}