25 lut 2009

Zaokrąglanie liczby w JS

alert(n_height);

---------------------------
Windows Internet Explorer
---------------------------
811.267175572519
---------------------------
OK  
---------------------------

n=(Math.ceil(n_height*100))/100;
alert(n);

---------------------------
Windows Internet Explorer
---------------------------
811.27
---------------------------
OK  
---------------------------

n_height  = parseInt(n_height);

---------------------------
Windows Internet Explorer
---------------------------
811
---------------------------
OK  
---------------------------