ma come l'hai usato![]()
vedi se così va bene:
codice:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Pagina senza titolo</title> <script language="javascript" type="text/javascript"> // <!CDATA[ function Button1_onclick() { var x = 94.8 * 0.95; document.getElementById("div1").innerHTML = x; document.getElementById("div2").innerHTML = fix(x); } //------------------------------------------------ //Arrotonda number a dec cifre //se dec non è specificato, arrotonda a 10 cifre //------------------------------------------------ function fix(number, dec) { var n =(dec >=0)? Math.pow(10,dec) : 1e10; return Math.round(number * n) / n; } // ]]> </script> </head> <body> <input id="Button1" type="button" value="button" onclick="return Button1_onclick()" /> <div id="div1"> </div> <div id="div2"> </div> </body> </html>

Rispondi quotando