Ver Mensaje Individual
  #3 (permalink)  
Antiguo 09/04/2008, 14:25
a2a2
 
Fecha de Ingreso: marzo-2008
Mensajes: 303
Antigüedad: 16 años, 10 meses
Puntos: 4
Re: como hacer formato monetario

No lo he probado, pero he encontrado éste código en http://www.web-source.net/web_development/currency_formatting.htm:

Código:
function CommaFormatted(amount)
{
	var delimiter = ","; // replace comma if desired
	var a = amount.split('.',2)
	var d = a[1];
	var i = parseInt(a[0]);
	if(isNaN(i)) { return ''; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	if(d.length < 1) { amount = n; }
	else { amount = n + '.' + d; }
	amount = minus + amount;
	return amount;
}
// end of function CommaFormatted()