3
I’m trying to call the name variable within the forward functionQuadro. But it’s not working.
var pergunta = document.querySelectorAll(".pergunta");
var indiceAtual = 0;
function iniciar(){
pergunta[0].style.display = "block";
}
function avancaPergunta(){ //pula de pergunta em pergunta
var nome = document.getElementById("nome").value;
var mesNascimento = document.getElementById("mes-nascimento").value;
var cor = document.getElementById("cor").value;
pergunta[indiceAtual].style.display = "none";
if (indiceAtual +1 >= pergunta.length){
alert("você terminou o quiz");
return;
}
pergunta[indiceAtual+1].style.display = "block";
indiceAtual++;
}
function avancaQuadro(){
document.getElementById("resultado22").innerHTML = nome;
}
Roberto, I made this change.. I put the name variable outside the function, but it’s not rolling... I don’t know if the problem var name = Document.getElementById("name"). value; Function avancaPergunta(){ //pula of question in question question[indiceAtual].style.display = "None"; if (indiceAtual +1 >= question.length){ Alert("you finished the quiz"); Return; } question[indiceAtual+1].style.display = "block"; indiceAtual++; } Function advantageQuadro(){ Document.getElementById("resultado22"). innerHTML = name; }
– Christian Silva
Call the variable without the . value at the end and inside the forward functionTuadro, try setting the innerHTML with name.value; to see if it works then.
– Roberto Griel Filho