ciao a tutti,
ho due problemi su una funzione
1)dovrei obbligare ad inserire nel campo acc solo i numeri e il punto
2)non capisco perchè se inserisco un valore più alto adesempio 80 il calcolo funziona, ma se inserisco 100 non funziona più
questa è la pagina intera
codice:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>CASSA</title> <script> function inserimentoprezzo() { var prezzo = 50; prezzo1 = prezzo*20/100; prezzo -= prezzo1; window.alert ("L'ACCONTO MINIMO DEVE ESSERE € "+prezzo1+" PARI AL 20% DEL TOTALE"); document.getElementById('tot').value = 50; document.getElementById('tot').disabled="disabled"; document.getElementById('rim').value=prezzo; document.getElementById('rim').disabled="disabled" document.getElementById('acc').value = prezzo1; } function calc(){ var acconto = document.getElementById('acc').value; var totale = document.getElementById('tot').value; var rimanenza = document.getElementById('rim').value; if (acconto > totale){ rimanenza = acconto - totale; window.alert ("ATTENZIONE L'ACCONTO E' MAGGIORE DELL'IMPORTO TOTALE \n IL RESTO DA DARE E' € "+rimanenza); document.getElementById('rim').value = "0"; document.getElementById('acc').value = totale; }else{ rimanenza = totale - acconto; document.getElementById('rim').value = rimanenza; } } </script> </head> <body bgcolor="white" text="black" link="blue" vlink="purple" alink="red" onLoad="inserimentoprezzo()"> TOTALE € <input name="tot" type="text" class="style2" id="tot" size="12"> - ACCONTO € <input name="acc" type="text" class="style2" id="acc" onChange="calc()" size="12"> - RIMANENZA € <input name="rim" type="text" class="style2" id="rim" size="12"> </body> </html>Grazie

Grazie
Rispondi quotando