49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
function test()
|
|
{
|
|
document.getElementById("demo").style.color = "red";
|
|
document.getElementById("demo").style.backgroundColor = "yellow";
|
|
document.getElementById("demo").innerHTML = "Title!";
|
|
}
|
|
var nextquestion;
|
|
var nbQuestion;
|
|
function startQuiz(j)
|
|
{
|
|
nextquestion = 1;
|
|
nbQuestion = j;
|
|
document.getElementById("test1").style.display = "block";
|
|
document.getElementById("strt").disabled = "true";
|
|
}
|
|
|
|
function tog(j)
|
|
{
|
|
|
|
var chk = [];
|
|
var test = true
|
|
for (i=0;i<j;i++)
|
|
{
|
|
chk[i] = document.getElementById("tgl"+(i+1)+nextquestion);
|
|
test = test && String(chk[i].checked) == chk[i].getAttribute("attribut");
|
|
}
|
|
|
|
if (test)
|
|
{
|
|
document.getElementById("answer"+nextquestion).innerHTML = "correct";
|
|
document.getElementById("answer"+nextquestion).style.color = "#00ff00";
|
|
} else
|
|
{
|
|
document.getElementById("answer"+nextquestion).innerHTML = "incorrect";
|
|
document.getElementById("answer"+nextquestion).style.color = "#ff0000";
|
|
}
|
|
document.getElementById("answer"+nextquestion).style.display = "block";
|
|
document.getElementById("tgl1"+nextquestion).disabled = "true";
|
|
document.getElementById("tgl2"+nextquestion).disabled = "true";
|
|
document.getElementById("sub1").disabled = "true";
|
|
nextquestion = nextquestion + 1;
|
|
if (nextquestion<=nbQuestion)
|
|
{
|
|
document.getElementById("test"+nextquestion).style.display = "block";
|
|
}
|
|
|
|
}
|
|
|