{article JavaScript Table of Content}{title} {text} {/article}
Returns a string representation of a number in fixed-point notation, containing fractionDigits digits after the decimal point.
Example 1
<script>
var num = new Number(123);
var fix = num.toFixed();
document.write(fix);
document.write("<br/>");
num = new Number(123.456);
fix = num.toFixed(2);
document.write(fix);
</script>
{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">
<script><br>
var num = new Number(123);<br>
var fix = num.toFixed();<br>
document.write(fix);<br>
document.write("<br/>");<br>
<br>
num = new Number(123.456);<br>
fix = num.toFixed(2);<br>
document.write(fix);<br>
</script><br>
</pre>
<script language="javascript" type="text/javascript">
// You can place JavaScript like this
</script>
<?php
// You can place PHP like this
?>
{/source}
{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><br>
<head><br>
<title>title</title><br>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br>
<meta name="description" content="" /><br>
<meta name="keywords" content="" /><br>
<meta name="robots" content="index,follow" /><br>
<link rel="stylesheet" type="text/css" href="styles.css" /><br>
</head><br>
<br>
<body><br>
<script><br>
var num = new Number(123);<br>
var fix = num.toFixed();<br>
document.write(fix);<br>
document.write("<br/>");<br>
<br>
num = new Number(123.456);<br>
fix = num.toFixed(2);<br>
document.write(fix);<br>
</script><br>
</body><br>
</html><br>
</pre>
<script language="javascript" type="text/javascript">
// You can place JavaScript like this
</script>
<?php
// You can place PHP like this
?>
{/source}
Output Esample 1
123
123.46
Example 2
<script>
var num = new Number(123);
var fix = num.toFixed();
document.write(fix);
document.write("<br/>");
num = new Number(123.456);
fix = num.toFixed(6);
document.write(fix);
</script>
{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><br>
<head><br>
<title>title</title><br>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br>
<meta name="description" content="" /><br>
<meta name="keywords" content="" /><br>
<meta name="robots" content="index,follow" /><br>
<link rel="stylesheet" type="text/css" href="styles.css" /><br>
</head><br>
<br>
<body><br>
<script><br>
var num = new Number(123);<br>
var fix = num.toFixed();<br>
document.write(fix);<br>
document.write("<br/>");<br>
<br>
num = new Number(123.456);<br>
fix = num.toFixed(6);<br>
document.write(fix);<br>
</script><br>
</body><br>
</html><br>
</pre>
<script language="javascript" type="text/javascript">
// You can place JavaScript like this
</script>
<?php
// You can place PHP like this
?>
{/source}
Output Example 2
123
123.456000