Originariamente inviato da vinci840
io non ci riesco...potresti farmi un esempio più completo?
poi come faccio a far comparire il risultato in un campo testo?
ecco un esempio pratico:
codice:
<html>
<head>
<title>Prova</title>
<script language="JavaScript">
function somma(v,s){
var f=document.nomeform;
var realvalue=(f.c.value=="")?0:parseInt(f.c.value);
if(s) f.c.value=realvalue+parseInt(v);
else f.c.value=realvalue-parseInt(v);
}
</script>
</head>
<body>
<form name="nomeform">
<input type="checkbox" value="10" onclick="somma(this.value, this.checked);" name="c1"/>
<input type="checkbox" value="20" onclick="somma(this.value, this.checked);" name="c2"/>
<input type="checkbox" value="30" onclick="somma(this.value, this.checked);" name="c3"/>
<input type="text" name="c" value="0"/>
</form>
</body>
</html>
ciao