<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://wiki.stephanschlegel.de/index.php?action=history&amp;feed=atom&amp;title=JavaScript_-_Zahlen_formatieren</id>
	<title>JavaScript - Zahlen formatieren - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.stephanschlegel.de/index.php?action=history&amp;feed=atom&amp;title=JavaScript_-_Zahlen_formatieren"/>
	<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=JavaScript_-_Zahlen_formatieren&amp;action=history"/>
	<updated>2026-05-09T05:11:37Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in Wikizone</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wiki.stephanschlegel.de/index.php?title=JavaScript_-_Zahlen_formatieren&amp;diff=19904&amp;oldid=prev</id>
		<title>134.3.241.116: Die Seite wurde neu angelegt: „Hier gibt es schicke Tools und Plugins. Etwa für jQuery   https://code.google.com/p/jquery-numberformatter/  Aber oft reicht auch eine kleine Funktion z.B. diese…“</title>
		<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=JavaScript_-_Zahlen_formatieren&amp;diff=19904&amp;oldid=prev"/>
		<updated>2013-07-26T15:01:28Z</updated>

		<summary type="html">&lt;p&gt;Die Seite wurde neu angelegt: „Hier gibt es schicke Tools und Plugins. Etwa für jQuery   https://code.google.com/p/jquery-numberformatter/  Aber oft reicht auch eine kleine Funktion z.B. diese…“&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Hier gibt es schicke Tools und Plugins. Etwa für jQuery &lt;br /&gt;
&lt;br /&gt;
https://code.google.com/p/jquery-numberformatter/&lt;br /&gt;
&lt;br /&gt;
Aber oft reicht auch eine kleine Funktion z.B. diese:&lt;br /&gt;
&lt;br /&gt;
Quelle: http://stackoverflow.com/questions/149055/how-can-i-format-numbers-as-money-in-javascript?page=1&amp;amp;tab=votes#tab-top (2013-07)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/* &lt;br /&gt;
decimal_sep: character used as deciaml separtor, it defaults to &amp;#039;.&amp;#039; when omitted&lt;br /&gt;
thousands_sep: char used as thousands separator, it defaults to &amp;#039;,&amp;#039; when omitted&lt;br /&gt;
*/&lt;br /&gt;
Number.prototype.toMoney = function(decimals, decimal_sep, thousands_sep)&lt;br /&gt;
{ &lt;br /&gt;
   var n = this,&lt;br /&gt;
   c = isNaN(decimals) ? 2 : Math.abs(decimals), //if decimal is zero we must take it, it means user does not want to show any decimal&lt;br /&gt;
   d = decimal_sep || &amp;#039;.&amp;#039;, //if no decimal separator is passed we use the dot as default decimal separator (we MUST use a decimal separator)&lt;br /&gt;
&lt;br /&gt;
   /*&lt;br /&gt;
   according to [http://stackoverflow.com/questions/411352/how-best-to-determine-if-an-argument-is-not-sent-to-the-javascript-function]&lt;br /&gt;
   the fastest way to check for not defined parameter is to use typeof value === &amp;#039;undefined&amp;#039; &lt;br /&gt;
   rather than doing value === undefined.&lt;br /&gt;
   */   &lt;br /&gt;
   t = (typeof thousands_sep === &amp;#039;undefined&amp;#039;) ? &amp;#039;,&amp;#039; : thousands_sep, //if you don&amp;#039;t want to use a thousands separator you can pass empty string as thousands_sep value&lt;br /&gt;
&lt;br /&gt;
   sign = (n &amp;lt; 0) ? &amp;#039;-&amp;#039; : &amp;#039;&amp;#039;,&lt;br /&gt;
&lt;br /&gt;
   //extracting the absolute value of the integer part of the number and converting to string&lt;br /&gt;
   i = parseInt(n = Math.abs(n).toFixed(c)) + &amp;#039;&amp;#039;, &lt;br /&gt;
&lt;br /&gt;
   j = ((j = i.length) &amp;gt; 3) ? j % 3 : 0; &lt;br /&gt;
   return sign + (j ? i.substr(0, j) + t : &amp;#039;&amp;#039;) + i.substr(j).replace(/(\d{3})(?=\d)/g, &amp;quot;$1&amp;quot; + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : &amp;#039;&amp;#039;); &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Anwendung:&lt;br /&gt;
 price = parseFloat(price).toMoney(2, &amp;#039;,&amp;#039;, &amp;#039;.&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
In diesem Fall war price vorher ein String und wird deshalb über parseFloat zuerst in eine Zahl umgewandelt. &lt;br /&gt;
&lt;br /&gt;
Parameter:&lt;br /&gt;
 Anzahl der Ziffern nach dem Komma&lt;br /&gt;
 Komma - Trennzeichen&lt;br /&gt;
 Tausender - Trennzeichen&lt;/div&gt;</summary>
		<author><name>134.3.241.116</name></author>
	</entry>
</feed>