questa č una vecchia funzione, chissā se funziona ancora :master:

codice:
//-------------------------------------------------
//arrotonda il numero num a dec decimali
// num = numero da formattare
//dec  = numero di decimali, predefinito = 2
//sepm = separatore migliaia, predefinito = spazio
//sepd = separatore decimale, predefinito = virgola
//-------------------------------------------------
function FormatNumber(num, dec, sepm, sepd)
{
   	if(dec == undefined || dec == "") dec = 2;
   	if(sepm == undefined || sepm == "") sepm = " "; sepm = sepm.substr(0,1);
   	if(sepd == undefined || sepd == "") sepd = ","; sepd = sepd.substr(0,1);
   	
   	var d = Math.pow(10,dec);
   	
   	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num)) num = "0";
	sign = (num == (num = Math.abs(num)));
		
	num = Math.floor(num * d + 0.50000000001);
	cents = num % d;
	num = Math.floor(num / d).toString();
	if(cents < 10) cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length - (1+i))/3); i++)
	    num = num.substring(0, num.length - (4 * i + 3)) + sepm + num.substring(num.length - (4 * i + 3));
    return (((sign)?'':'-') + '' + num + sepd + cents);
}