Guarda i commenti!

codice:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>

<input type="hidden" name="scelta_effettuata" id="scelta_effettuata">

<script type="text/javascript">

matrice_domande= new Array("domanda1","domanda2","domanda3","domanda4","domanda5");
matrice_risposte= new Array("A","B","C","D","A");

// inizializzo una variabile contatore
var contatore = 0;

Q = matrice_domande.length;
quale_domanda=Math.round(Math.random()*(Q-1));


function mostra_domanda() {
    // ogni volta che devo mostrare una domanda, incremento il contatore e, 
    // se minore  o uguale a 4, invece della domanda faccio vedere 'gioco finito', poi
    // disabilito i pulsanti
    // altrimenti faccio vedere la domanda
    contatore++;
    if (contatore <= 4) {
        document.getElementById("domanda").innerHTML=matrice_domande[quale_domanda];
    }
    else {
        document.getElementById("domanda").innerHTML="Gioco Finito!";
        document.getElementById("BottoneA").disabled = true;
        document.getElementById("BottoneB").disabled = true;
        document.getElementById("BottoneC").disabled = true;
        document.getElementById("BottoneD").disabled = true;
    }
}

function prendiValore(scelta){
    document.getElementById("scelta_effettuata").value= scelta;
    if (scelta==matrice_risposte[quale_domanda]) {
        alert("La risposta era corretta")
        quale_domanda=Math.round(Math.random()*(Q-1));
        mostra_domanda();
    }
    else {
        alert("La risposta era sbagliata")
        quale_domanda=Math.round(Math.random()*(Q-1));
        mostra_domanda();
    }
}
</script>
</head>
<body>
<div id="domanda"></div>



<button id="BottoneA" onClick="prendiValore('A');">scegli A</button>
<button id="BottoneB" onClick="prendiValore('B');">scegli B</button>
<button id="BottoneC" onClick="prendiValore('C');">scegli C</button>
<button id="BottoneD" onClick="prendiValore('D');">scegli D</button>
<script type="text/javascript">
// Attenzione: la chiamata è stata messa qua per essere sicuri che il browser sappia dov'è il div!
// inizializzo, per sicurezza, i bottoni abilitati
document.getElementById("BottoneA").disabled = false;
document.getElementById("BottoneB").disabled = false;
document.getElementById("BottoneC").disabled = false;
document.getElementById("BottoneD").disabled = false;

mostra_domanda();
</script>


</body>

</html>
HTH
Zappa