• Benvenuto in Making Videogames!
  • Dai sfogo alla tua fantasia!
  • Crea il tuo Videogioco!
Benvenuto ospite! Login Registrati




Valutazione discussione:
  • 0 voto(i) - 0 media
  • 1
  • 2
  • 3
  • 4
  • 5
Problema javascript
#9
i calcoli non li fa perché mancava <form name="calcola">

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>
<form name="calcola">
<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>

non so come farne checkare solo 1, non conosco javascript.

volendo (che io sono capace di fare) si possono mettere degli if aggiuntivi a prova() per fargli fare un alert se ce nè spuntato più di uno, però è sicuramente meno elegante del primo modo.
 
Rispondi
  


Messaggi in questa discussione
Problema javascript - da Lorenz - 09-10-2010, 05:22 PM
RE: Problema javascript - da steve - 09-10-2010, 05:29 PM
RE: Problema javascript - da Lorenz - 09-10-2010, 05:33 PM
RE: Problema javascript - da steve - 09-10-2010, 05:50 PM
RE: Problema javascript - da Lorenz - 09-10-2010, 05:55 PM
RE: Problema javascript - da Lorenz - 10-10-2010, 07:23 PM
RE: Problema javascript - da steve - 10-10-2010, 08:22 PM
RE: Problema javascript - da Lorenz - 10-10-2010, 08:34 PM
RE: Problema javascript - da steve - 10-10-2010, 09:00 PM
RE: Problema javascript - da Lorenz - 10-10-2010, 09:06 PM
RE: Problema javascript - da steve - 10-10-2010, 09:11 PM

Vai al forum:


Browsing: 1 Ospite(i)