10-10-2010, 08:22 PM
(Questo messaggio è stato modificato l'ultima volta il: 10-10-2010, 08:23 PM da steve.)
non devi mettere tante funzioni prova() con un IF per ognuna funzione. devi mettere una sola funzione prova() con dentro tanti if
inoltre ti consiglio di impostare che si può mettere una sola scelta nel checkbox, altrimenti uno li può anche spuntare tutti
Codice:
<html>
<body>
<script language="javascript">
document.write("Riempi le caselle con il numero delle stelle da te viste poi clicca sul pulsante per fare una delle tre operazioni");
function prova()
{
if(stelle.scelta[0].checked)
{
alert("Grazie mille !! ");
}
if(stelle.scelta[1].checked)
{
alert("Grazie");
}
if(stelle.scelta[2].checked)
{
alert("Ho fatto del mio meglio ! ");
}
if(stelle.scelta[3].checked)
{
alert("Antipatico ci ho perso un pomeriggio ! ");
}
}
function ecco(){
a=eval(document.calcola.uno.value);
b=eval(document.calcola.due.value);
c=eval(document.calcola.tre.value);
d=eval(document.calcola.quattro.value);
e=eval(document.calcola.cinque.value);
f=eval(document.calcola.sei.value);
g=eval(document.calcola.sette.value);
h=eval(document.calcola.otto.value);
i=eval(document.calcola.nove.value);
j=eval(document.calcola.dieci.value);
k=eval(document.calcola.undici.value);
l=eval(document.calcola.dodici.value);
m=eval(document.calcola.tredici.value);
n=eval(document.calcola.quattordici.value);
o=eval(document.calcola.quindici.value);
p=eval(document.calcola.sedici.value);
q=eval(document.calcola.diciasette.value);
r=eval(document.calcola.diciotto.value);
s=eval(document.calcola.diciannove.value);
t=eval(document.calcola.venti.value);
u=eval(document.calcola.ventuno.value);
v=eval(document.calcola.ventidue.value);
w=eval(document.calcola.ventitre.value);
x=eval(document.calcola.ventiquattro.value);
y=eval(document.calcola.venticinque.value);
z=eval(document.calcola.ventisei.value);
ab=eval(document.calcola.ventisette.value);
cd=eval(document.calcola.ventotto.value);
ef=eval(document.calcola.ventinove.value);
gh=eval(document.calcola.trenta.value);
document.calcola.trentuno.value=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z+ab+cd+ef+gh;
}
function bhe(){
a=eval(document.calcola.uno.value);
b=eval(document.calcola.due.value);
c=eval(document.calcola.tre.value);
d=eval(document.calcola.quattro.value);
e=eval(document.calcola.cinque.value);
f=eval(document.calcola.sei.value);
g=eval(document.calcola.sette.value);
h=eval(document.calcola.otto.value);
i=eval(document.calcola.nove.value);
j=eval(document.calcola.dieci.value);
k=eval(document.calcola.undici.value);
l=eval(document.calcola.dodici.value);
m=eval(document.calcola.tredici.value);
n=eval(document.calcola.quattordici.value);
o=eval(document.calcola.quindici.value);
p=eval(document.calcola.sedici.value);
q=eval(document.calcola.diciasette.value);
r=eval(document.calcola.diciotto.value);
s=eval(document.calcola.diciannove.value);
t=eval(document.calcola.venti.value);
u=eval(document.calcola.ventuno.value);
v=eval(document.calcola.ventidue.value);
w=eval(document.calcola.ventitre.value);
x=eval(document.calcola.ventiquattro.value);
y=eval(document.calcola.venticinque.value);
z=eval(document.calcola.ventisei.value);
ab=eval(document.calcola.ventisette.value);
cd=eval(document.calcola.ventotto.value);
ef=eval(document.calcola.ventinove.value);
gh=eval(document.calcola.trenta.value);
document.calcola.trentadue.value=(a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z+ab+cd+ef+gh)/30;
}
function bha(){
a=eval(document.calcola.uno.value);
b=eval(document.calcola.due.value);
c=eval(document.calcola.tre.value);
d=eval(document.calcola.quattro.value);
e=eval(document.calcola.cinque.value);
f=eval(document.calcola.sei.value);
g=eval(document.calcola.sette.value);
h=eval(document.calcola.otto.value);
i=eval(document.calcola.nove.value);
j=eval(document.calcola.dieci.value);
k=eval(document.calcola.undici.value);
l=eval(document.calcola.dodici.value);
m=eval(document.calcola.tredici.value);
n=eval(document.calcola.quattordici.value);
o=eval(document.calcola.quindici.value);
p=eval(document.calcola.sedici.value);
q=eval(document.calcola.diciasette.value);
r=eval(document.calcola.diciotto.value);
s=eval(document.calcola.diciannove.value);
t=eval(document.calcola.venti.value);
u=eval(document.calcola.ventuno.value);
v=eval(document.calcola.ventidue.value);
w=eval(document.calcola.ventitre.value);
x=eval(document.calcola.ventiquattro.value);
y=eval(document.calcola.venticinque.value);
z=eval(document.calcola.ventisei.value);
ab=eval(document.calcola.ventisette.value);
cd=eval(document.calcola.ventotto.value);
ef=eval(document.calcola.ventinove.value);
gh=eval(document.calcola.trenta.value);
document.calcola.trentatre.value=(a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z+ab+cd+ef+gh)/30*700
}
</script>
<input type="text" name="uno"/>
<input type="text" name="due"/>
<input type="text" name="tre"/>
<input type="text" name="quattro"/>
<input type="text" name="cinque"/>
<input type="text" name="sei"/>
<input type="text" name="sette"/>
<input type="text" name="otto"/>
<input type="text" name="nove"/>
<input type="text" name="dieci"/>
<br>
<input type="text" name="undici"/>
<input type="text" name="dodici"/>
<input type="text" name="tredici"/>
<input type="text" name="quattordici"/>
<input type="text" name="quindici"/>
<input type="text" name="sedici"/>
<input type="text" name="diciasette"/>
<input type="text" name="diciotto"/>
<input type="text" name="diciannove"/>
<input type="text" name="venti"/>
<br>
<input type="text" name="ventuno"/>
<input type="text" name="ventidue"/>
<input type="text" name="ventitre"/>
<input type="text" name="ventiquattro"/>
<input type="text" name="venticinque"/>
<input type="text" name="ventisei"/>
<input type="text" name="ventisette"/>
<input type="text" name="ventotto"/>
<input type="text" name="ventinove"/>
<input type="text" name="trenta"/>
<br>
<input type="text" name="trentuno"/>
<input type="button" value="NUMERO TOTALE DI STELLE" onclick="ecco()"/>
<br>
<input type="text" name="trentadue"/>
<input type="button" value="NUMERO MEDIO DI STELLE PER CAMPIONE" onclick="bhe()"/>
<br>
<input type="text" name="trentatre"/>
<input type="button" value="NUMERO APPROSSIMATO DI STELLE IN CIELO" onclick="bha()"/>
<br>
<p>Ti è piaciuto ? </p>
<form method="get" onsubmit="prova()" name="stelle">
<input type="checkbox" value="ok" name="scelta">Sì
<br>
<input type="checkbox" value="ok" name="scelta">Non male
<br>
<input type="checkbox" value="ok" name="scelta">Così così
<br>
<input type="checkbox" value="ok" name="scelta">No
<br>
<input type="submit" value="INVIA">
</form>
</body>
</html>
inoltre ti consiglio di impostare che si può mettere una sola scelta nel checkbox, altrimenti uno li può anche spuntare tutti