<form>
<p>Domanda 1 ?</p>
<input type=radio value="a" name="1" onClick="Engine(1, this.value)">risposta 1<br>
<input type=radio value="b" name="1" onClick="Engine(1, this.value)">risposta 2<br>
<input type=radio value="c" name="1" onClick="Engine(1, this.value)">risposta 3<br>
<input type=radio value="d" name="1" onClick="Engine(1, this.value)">risposta 4<p>
<p>Domanda 2 ?</p>
<input type=radio value="a" name="2" onClick="Engine(2, this.value)">risposta 1<br>
<input type=radio value="b" name="2" onClick="Engine(2, this.value)">risposta 2<br>
<input type=radio value="c" name="2" onClick="Engine(2, this.value)">risposta 3<br>
<input type=radio value="d" name="2" onClick="Engine(2, this.value)">risposta 4<p>
<p>Domanda 3 ?</p>
<input type=radio value="a" name="3" onClick="Engine(3, this.value)">risposta 1<br>
<input type=radio value="b" name="3" onClick="Engine(3, this.value)">risposta 2<br>
<input type=radio value="c" name="3" onClick="Engine(3, this.value)">risposta 3<br>
<input type=radio value="d" name="3" onClick="Engine(3, this.value)">risposta 4<p>
<input type=button onClick="window.inizio= new Date(); countdown('0:2:3');"value="inizio">
<input type=button onClick="nextlevel()" value="Test finito, accedi alla pagina">
</form>
un quiz con quattro possibili risposte...ho uno script che mi indica se la risposta esatta o errata..e la risposta esatta del quiz. tutto ciò attraverso un getelementbyid....
vorrei sapere se è possibile indicare anche le risposte date dall'utente...
ho provato in tanti modi ma non sto riuscendo...mi aiutate?
qui di seguito lo script:
var name= prompt("per favore inserisci il tuo nome","");
// Prelevato su http://www.web-link.it
var ans = new Array;
var done = new Array;
var stat = new Array;
var score = 0;
var count = 0;
ans[1] = "d";
ans[2] = "b";
ans[3] = "b";
ans[4] = "d";
ans[5] = "a";
ans[6] = "c";
ans[7] = "c";
ans[8] = "d";
ans[9] = "a";
ans[10] = "c";
function Engine( question, answer ) {
if ( answer != ans[ question ] ) {
if ( ! done[ question ] ) {
done[ question ] = -1;
stat[ question ] = false;
count++;
} else {
alert( "Hai gia risposto a questa domanda!" );
}
} else {
if ( ! done[ question ] ) {
done[ question ] = -1;
score++;
stat[ question ] = true;
count++;
} else {
alert( "Hai gia risposto a questa domanda!" );
}
}
if ( count == ans.length ) { NextLevel()}
}
function NextLevel () {
var htm = "<span style='color:#BCF2ED'>Ciao "+name+", il tuo punteggio è di<span style='color:white'> " + score + "</span> su <span style='color: white'>" + (ans.length-1) +"</span>" +
"<br><br>";
htm += " <span style='color:white'>Resoconto risposte (tra parentesi le risposte esatte del quiz)</span><br><br>";
for ( var j = 1; j < stat.length; j++) {
htm += "<span style='color:white'>Risposta " + j+":</span> <span style='color:"+ ( stat[ j ] ? "#BCF2ED'>esatta" : "#BCF2ED'>errata")+"</span><span style='color:#BCF2ED'> ("+ans[j]+")</span><br><br>";
}
htm += "<a target='_blank' href='quiz1ver.htm'>vedi risposte</a>";
document.getElementById( 'risultato' ).innerHTML = htm;
}
<p>Domanda 1 ?</p>
<input type=radio value="a" name="1" onClick="Engine(1, this.value)">risposta 1<br>
<input type=radio value="b" name="1" onClick="Engine(1, this.value)">risposta 2<br>
<input type=radio value="c" name="1" onClick="Engine(1, this.value)">risposta 3<br>
<input type=radio value="d" name="1" onClick="Engine(1, this.value)">risposta 4<p>
<p>Domanda 2 ?</p>
<input type=radio value="a" name="2" onClick="Engine(2, this.value)">risposta 1<br>
<input type=radio value="b" name="2" onClick="Engine(2, this.value)">risposta 2<br>
<input type=radio value="c" name="2" onClick="Engine(2, this.value)">risposta 3<br>
<input type=radio value="d" name="2" onClick="Engine(2, this.value)">risposta 4<p>
<p>Domanda 3 ?</p>
<input type=radio value="a" name="3" onClick="Engine(3, this.value)">risposta 1<br>
<input type=radio value="b" name="3" onClick="Engine(3, this.value)">risposta 2<br>
<input type=radio value="c" name="3" onClick="Engine(3, this.value)">risposta 3<br>
<input type=radio value="d" name="3" onClick="Engine(3, this.value)">risposta 4<p>
<input type=button onClick="window.inizio= new Date(); countdown('0:2:3');"value="inizio">
<input type=button onClick="nextlevel()" value="Test finito, accedi alla pagina">
</form>
un quiz con quattro possibili risposte...ho uno script che mi indica se la risposta esatta o errata..e la risposta esatta del quiz. tutto ciò attraverso un getelementbyid....
vorrei sapere se è possibile indicare anche le risposte date dall'utente...
ho provato in tanti modi ma non sto riuscendo...mi aiutate?
qui di seguito lo script:
var name= prompt("per favore inserisci il tuo nome","");
// Prelevato su http://www.web-link.it
var ans = new Array;
var done = new Array;
var stat = new Array;
var score = 0;
var count = 0;
ans[1] = "d";
ans[2] = "b";
ans[3] = "b";
ans[4] = "d";
ans[5] = "a";
ans[6] = "c";
ans[7] = "c";
ans[8] = "d";
ans[9] = "a";
ans[10] = "c";
function Engine( question, answer ) {
if ( answer != ans[ question ] ) {
if ( ! done[ question ] ) {
done[ question ] = -1;
stat[ question ] = false;
count++;
} else {
alert( "Hai gia risposto a questa domanda!" );
}
} else {
if ( ! done[ question ] ) {
done[ question ] = -1;
score++;
stat[ question ] = true;
count++;
} else {
alert( "Hai gia risposto a questa domanda!" );
}
}
if ( count == ans.length ) { NextLevel()}
}
function NextLevel () {
var htm = "<span style='color:#BCF2ED'>Ciao "+name+", il tuo punteggio è di<span style='color:white'> " + score + "</span> su <span style='color: white'>" + (ans.length-1) +"</span>" +
"<br><br>";
htm += " <span style='color:white'>Resoconto risposte (tra parentesi le risposte esatte del quiz)</span><br><br>";
for ( var j = 1; j < stat.length; j++) {
htm += "<span style='color:white'>Risposta " + j+":</span> <span style='color:"+ ( stat[ j ] ? "#BCF2ED'>esatta" : "#BCF2ED'>errata")+"</span><span style='color:#BCF2ED'> ("+ans[j]+")</span><br><br>";
}
htm += "<a target='_blank' href='quiz1ver.htm'>vedi risposte</a>";
document.getElementById( 'risultato' ).innerHTML = htm;
}