Comma Separator
Head:
<script
type="text/javascript">
function addCommas(num) {
num += ”;
var n1 = num.split(‘.’);
var n2 = n1[0];
var n3 = n1.length > 1 ? ‘.’ + n1[1] : ”;
var temp = /(d+)(d{3})/;
while (temp.test(n2)) {
n2 = n2.replace(temp, ” + ‘,’ + ”);
}
var out = return n2 + n3;
document.write(out);
}
</script>
function addCommas(num) {
num += ”;
var n1 = num.split(‘.’);
var n2 = n1[0];
var n3 = n1.length > 1 ? ‘.’ + n1[1] : ”;
var temp = /(d+)(d{3})/;
while (temp.test(n2)) {
n2 = n2.replace(temp, ” + ‘,’ + ”);
}
var out = return n2 + n3;
document.write(out);
}
</script>
Body:
<script
type="text/javascript">addCommas("4550989023");</script>
This snippet
would be used mainly by sites that use numbers often. This snippet will keep
your numbers looking the same across the board. All you have to do is copy the
body line where you want to add a number and replace the number there with your
number.
No comments:
Post a Comment