Salve a tutti, già seguivo il sito per le ottime guide (e per ciò vi ringrazio :P).
Mi sono iscritto per chiedervi una cosa che mi fa scervellare da qualche giorno e che neanche il mio professore è riuscito a risolvere.
vi posto il codice dell'esercizio qui sotto, spero che possiate essere d'aiuto
(l'errore è che non mi si cancella la form usando la funzione reset() )
codice:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title> Esercizio su Javascript. </title> <script type="text/javascript"> function email() { } function confermaReset() { if (confirm("sicuro di voler resettare?")) document.ordine.reset(); } function moltiplica(nome, numero) { if(nome=="mouse") mouse = document.ordine.totaleMouse.value = numero * 16; if(nome=="tastiera") tastiera = document.ordine.totaleTastiera.value = numero * 25; if(nome=="stampante") stampante = document.ordine.totaleStampante.value = numero * 350; if(nome=="scanner") scanner = document.ordine.totaleScanner.value = numero * 200; } function calcoloSpesa() { document.ordine.totaleSpesa.value = mouse + tastiera + stampante + scanner; } function verifica(valore) { if (valore.value>20 || valore.value<0) { alert('Inserire un valore compreso tra 0 e 20'); valore.value=0; } else { moltiplica(valore.name, valore.value) } } function help() { window.open("http://www.google.it/", "mywindow"); } </script> </head> <body> <form name="ordine" action="mailto:wwkdd.ff"> <table border=1 cellpadding=3> <tr><th>Q.tà<th>Descrizione<th>Costo Unitario<th>Totale <tr><td><input onChange="verifica(this)" name="mouse" type="text" value="0" size=1><td>mouse<td align=right>16€<td><input name="totaleMouse" type="text" value="0"></input>€ <tr><td><input onChange="verifica(this)" type="text" name="tastiera" value="0" size=1><td>tastiera 105 tasti<td align=right>25€<td><input name="totaleTastiera" type="text" value="0"></input>€ <tr><td><input onChange="verifica(this)" type="text" value="0" name="stampante" size=1><td>stampante deskjet colori<td align=right>350€<td><input name="totaleStampante" type="text" value="0"></input>€ <tr><td><input onChange="verifica(this)" type="text" value="0" name="scanner" size=1><td>scanner A4 colori<td align=right>200€<td align=right><input name="totaleScanner" type="text" value="0"></input>€ <tr><td colspan=3 align="right">Totale Ordine<td><input type="text" name="totaleSpesa" value="0"> </table> <input type="button" value="Calcolo Spesa" onClick="calcoloSpesa()"> <input value="Resetta Ordine" name="reset" type="button" onClick="confermaReset()"> <input type="button" value="help" onClick="help()"><input type="text" value="inserisci qui la tua email"> </form> </body> </html>
se ho infranto qualche regola spero siate comprensivi :P