Prende il punto attualmente come separatore dei decimali... caso mai, divertiti un po' a fare il parse della stringa prima (per cambiare le virgole in punti, se presenti).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> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Iva</title> <script language="javascript" type="text/javascript"> function calcola(f) { var prezzov = Math.round(parseFloat(f.value)*100)/100; ivav = Math.round(prezzov*20)/100; totv = prezzov+ivav; f.form.iva.value = ivav; f.form.tot.value= totv; } </script> </head> <body> <form action="" method="post" name="prezzo" id="prezzo"> <table width="600" border="0" cellspacing="5" cellpadding="0"> <tr> <td><div align="right">Importo:</div></td> <td><input name="importo" type="text" id="importo" onkeyup="calcola(this);" /></td> </tr> <tr> <td><div align="right">IVA:</div></td> <td><input name="iva" type="text" id="iva" /></td> </tr> <tr> <td><div align="right">Totale Ivato: </div></td> <td><input name="tot" type="text" id="tot" /></td> </tr> </table> </form> </body> </html>
Ho anche fatto un po' di "formattazione", ciao.