Non ho ben capito. Comunque....
codice:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> <script language="JavaScript" type="text/javascript"> <!-- var cpVal = 0; var prevCp = ''; function cambiaValore(anId,unValore) { if (prevCp != '') { document.getElementById(prevCp).value='--'; } // if (prevCp != '') prevCp = anId; document.getElementById(prevCp).value=unValore; } // function cambiaValore(anId,unValore) function servizio(statoCB,unServizio,unValore) { if (statoCB) { document.getElementById(unServizio).value=unValore; } else { document.getElementById(unServizio).value='--'; } // if (statoCB) calcolaTotale(); } // function servizio(statoCB,unServizio,unValore) function calcolaTotale() { oColl = document.getElementsByTagName('INPUT'); tot = 0; for (i=0;i<oColl.length;i++) { curInput = oColl.item(i); if (curInput.type == 'checkbox' && curInput.name.substr(0,2) == 'SA') { serv = 'servizio' + curInput.value; if (curInput.checked && document.getElementById(serv).value != '--') { tot += parseFloat(document.getElementById(serv).value); } // if (curInput.checked && document.getElementById(serv).value != '--') } // if (curInput.type == 'checkbox' && curInput.name.substr(0,2) == 'SA') } // for (i=0;i<oColl.length;i++) document.getElementById('totale').value = tot; } // function calcolaTotale() //--> </script> </head> <body> <input type="radio" value="1" name="PH" onFocus="cambiaValore('cp1','18,00');"><input type="text" size="6" id="cp1" name="cp1" value="--" readonly> <input type="radio" value="2" name="PH" onFocus="cambiaValore('cp2','36,00');"><input type="text" size="6" id="cp2" name="cp2" value="--" readonly> <input type="radio" value="3" name="PH" onFocus="cambiaValore('cp3','48,00');"><input type="text" size="6" id="cp3" name="cp3" value="--" readonly> <input type="radio" value="4" name="PH" onFocus="cambiaValore('cp4','72,00');"><input type="text" size="6" id="cp4" name="cp4" value="--" readonly> <input type="radio" value="5" name="PH" onFocus="cambiaValore('cp5','45,60');"><input type="text" size="6" id="cp5" name="cp5" value="--" readonly> <hr /> <input type="checkbox" value="1" name="SA1" onClick="servizio(this.checked,'servizio1','1800');" > servizio 1 <input type="text" size="6" id="servizio1" name="servizio1" value="--" readonly> <input type="checkbox" value="2" name="SA2" onClick="servizio(this.checked,'servizio2','3360');" > servizio 2 <input type="text" size="6" id="servizio2" name="servizio2" value="--" readonly> <input type="checkbox" value="3" name="SA3" onClick="servizio(this.checked,'servizio3','6000');" > servizio 3 <input type="text" size="6" id="servizio3" name="servizio3" value="--" readonly> <input type="checkbox" value="4" name="SA4" onClick="servizio(this.checked,'servizio4','7200');" > servizio 4 <input type="text" size="6" id="servizio4" name="servizio4" value="--" readonly> Totale : <input type="text" size="6" name="totale" id="totale" readonly value="0"> </body> </html>

Rispondi quotando