Witam serdecznie forumowiczów!
Otóż dostałem zajawkę ostatnimi czasy na JS, po tym, jak nauczyciel nam projekt zadał i pomyślałem, że coś w nim wykminie, wydał mi się bardzo "prosty" :) I kolejny projekt mam na głowie teraz i znów chcę z niego skorzystać, jednakże wystąpił jakiś problem w kodzie, którego znaleźć nie potrafię... tyle czasu już zmarnowałem, a pewnie to jakaś pestka dla kogoś bynajmniej troszkę bardziej doświadczonego. Będę bardzo wdzięczny za chęć niesienia pomocy.
Błąd polega na tym, że jak klikam w btn1 to nic się nie dzieje, a powinny zmienić się innerHTML's dla h1, btn1, btn2, btn3 i btn4. Wcześniej działało, ale coś zrobiłem i nie trybi... Błagam Was...
<!DOCTYPE html>
<html>
<head>
<title>QUIZ</title>
<meta charset="utf-8">
<meta name="description" content="Przejdź quiz do końca, a odkryjesz jak wielki drzemie w Tobie potencjał...">
<meta name="keywords" content="quiz, sukces, człowiek, pytania">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body onload="quizLogic()">
<div id="topbar">QUIZ | Czy odniesiesz sukces?
</div>
<div id="container">
<div id="contentQuestion">
<h1 id="h1Index"></h1>
</div>
<div id="wrapper">
<div class="wrapperButton">
<button id="answer1" class="answerButton" onclick="onclickButtonA()"></button>
</div>
<div class="wrapperButton">
<button id="answer2" class="answerButton" onclick="onclickButtonB()"></button>
</div>
<div class="wrapperButton">
<button id="answer3" class="answerButton" onclick="onclickButtonC()"></button>
</div>
<div class="wrapperButton">
<button id="answer4" class="answerButton" onclick="onclickButtonD()"></button>
</div>
</div>
</div>
<script>
var nrQuestion = 1;
var points = 0;
var question = "";
var answerUser;
var anA = 3;
var anB = 2;
var anC = 1;
var anD = 0;
function quizLogic() {
questionsAnswers(nrQuestion);
}
function questionsAnswers(nrQuestion) {
if (nrQuestion = 1) {
document.getElementById("h1Index").innerHTML = 'Jak często czytasz książki? <span id="spanIndex">?</span>';
document.getElementById("answer1").innerHTML = 'MIESIĘCZNIE 1 / WIĘCEJ';
document.getElementById("answer2").innerHTML = 'OD 5 DO 12 ROCZNIE';
document.getElementById("answer3").innerHTML = 'OD 2 DO 5 ROCZNIE';
document.getElementById("answer4").innerHTML = 'PONIŻEJ 2 ROCZNIE';
} else if(nrQuestion = 2){
document.getElementById("h1Index").innerHTML = 'AAAAA <span id="spanIndex">?</span>';
document.getElementById("answer1").innerHTML = 'a';
document.getElementById("answer2").innerHTML = 'b';
document.getElementById("answer3").innerHTML = 'c';
document.getElementById("answer4").innerHTML = 'd';
}
}
function onclickButtonA() {
nrQuestion = 2;
quizLogic();
}
function onclickButtonB() {
}
function onclickButtonC() {
}
function onclickButtonD() {
}
</script>
</body>
</html>