Ciao a tutti !
Ho bisogno di un piccolo aiuto. Ho realizzato un semplice script per effettuare dei calcoli.
Il risultato del calcolo mi viene mostrato in tre elementi input.
La domanda è la seguente:
è possibile far visualizzare il risultato, invece che in un elemento input,
in un formato numerico che posso formattare con il tag font ?
Di seguito vi mostro il codice.
Grazie in anticipo !!!
codice:<html> <head> <script language="JavaScript"> <!-- function calcola() { var a = document.frutto.rendita.value; var b = document.frutto.tasso[document.frutto.tasso.selectedIndex].value; var c = document.frutto.eta[document.frutto.eta.selectedIndex].value; var d; var e; var f; var h; var m; if (b == "01") { m = "2.5"; d = (a * 1.05) * 110; if (c == "01") {f = "38"}; if (c == "02") {f = "36"}; }; if (b == "02") { m = "3"; d = (a * 1.05) * 100; if (c == "01") {f = "31.75"}; if (c == "02") {f = "30"}; }; e = (d/100)*m*f; h = d-e; document.frutto.valore.value = d; document.frutto.frutto.value = e; document.frutto.proprieta.value = h; } //--> </script> </head> <body> <form name="frutto"> Capitale <input type="text" name="rendita"> Tasso <select name="tasso"> <option value="" selected>Seleziona</option> <option value="01">2,5 %</option> <option value="02">3 %</option> </select> Età <select name="eta" onChange="calcola();"> <option value="0" selected>Seleziona</option> <option value="01">da 0 a 40 anni</option> <option value="02">da 41 a 60 anni</option> </select> Valore 1 <input type="text" name="valore"> Valore 2 <input type="text" name="frutto"> Valore 3 <input type="text" name="proprieta"> <input type="reset" value="Cancella"> </form> </body> </html>