previous

page 14

next
restricting the number of questions
function klick(el) {
g_count++;
...
function get_pic() {
clear();
if (g_count<g_questions) {
...
}
}
Adding scoring

Make sure that you add var g_score=0; to your globals.js.

function klick(el) {
g_count++;
var el_answer=document.getElementById(g_answer_id);
el_answer.style.backgroundColor='palegreen';
var id=el.id;
if (id!=g_answer_id) {
el.style.backgroundColor='red';
} else {
g_score++;
}
var el_score=document.getElementById('score');
el_score.textContent='Score: '+g_score+' / '+g_count;
setTimeout(get_pic,3000);
}
previous
next