Salve, qualcuno saprebbe dirmi perchè nel seguente codice, dopo toFixed(2) pr_iva restituisce NaN... questo però succede solo su Internet Explorer, menter su Chrome va tutto liscio
codice:function calcola_sconto(){ var perc = document.getElementById('sconto').value; if(perc == ''){perc = 0;} var prezzo = document.getElementById('tot').innerHTML.replace(",",".").replace(" €",""); var scontato = parseFloat(prezzo) / 100 * parseFloat(perc); scontato = scontato.toFixed(2); var tot_imp = prezzo - scontato; tot_imp = tot_imp.toFixed(2); var iva = document.getElementById('iva').innerHTML.replace("Totale Imposta IVA ","").replace("%: ",""); var pr_iva = parseFloat(tot_imp) / 100 * parseFloat(iva); var tot_ivato = parseFloat(tot_imp) + (parseFloat(tot_imp) / 100 * parseFloat(iva)); tot_ivato = tot_ivato.toFixed(2); pr_iva = pr_iva.toFixed(2); document.getElementById('tot_iva').innerHTML = pr_iva.replace(".",",")+" €"; document.getElementById('tot_ivato').innerHTML = tot_ivato.toString().replace(".",",")+" €"; document.getElementById('pr_scontato').innerHTML = scontato.toString().replace(".",",")+" €"; document.getElementById('tot_imp').innerHTML = tot_imp.toString().replace(".",",") +" €"; }

Rispondi quotando
