Scusami fcaldera,
ma con lo script che mi hai dato unito a quello mio non funziona:
codice:<script language="JavaScript" type="text/javascript"> function UpdateCost() { var sum = 0; var gn, elem; for (i=1; i<7; i++) { gn = 'lingue_'+i; elem = document.getElementById(gn); if (elem.checked == true) { sum += Number(elem.value); } } document.getElementById('q1').value = sum.toFixed(0); } </script> <script type="text/javascript"> window.onload = function() { var Fq1 = document.getElementById('q1'); var Fq2 = document.getElementById('q2'); var Fq3 = document.getElementById('q3'); Fq1.onchange = Fq2.onchange = Fq3.onchange = Fq1.onblur = Fq2.onblur = Fq3.onblur = calcola; function calcola() { var q1 = parseFloat(Fq1.value) || 0; var q2 = parseFloat(Fq2.value) || 0; var q3 = parseFloat(Fq3.value) || 0; document.getElementById('totale').value = (q1 * q2) + q3; } } </script> <form id="form1" name="form1" method="post" action="" > <input name="lingue_1" id="lingue_1" type="checkbox" value="1" onclick="UpdateCost()" /> <input name="lingue_2" id="lingue_2" type="checkbox" value="1" onclick="UpdateCost()" /> <input name="lingue_3" id="lingue_2" type="checkbox" value="1" onclick="UpdateCost()" /> <input name="lingue_4" id="lingue_4" type="checkbox" value="1" onclick="UpdateCost()" /> <input name="lingue_5" id="lingue_5" type="checkbox" value="1" onclick="UpdateCost()" /> <input name="lingue_6" id="lingue_6" type="checkbox" value="1" onclick="UpdateCost()" /> <label> <input name="q1" id="q1" type="text" value="0" /> * </label> <label> <input name="q2" id="q2" type="text" value="50.00" /> + </label> <label> <input name="q3" id="q3" type="text" value="84.00" /> </label> <label> <input type="text" name="totale" id="totale" value="?" /> </label> </form>
ho messo onchange ma non funziona.

Rispondi quotando