I have the following code based on JavaScript
:
var perguntas = new Array();
var respostas = new Array();
var totalPerguntas = 2;
perguntas[1] = "Pergunta um";
respostas[1] = "Resposta um";
perguntas[2] = "Pergunta dois";
respostas[2] = "Resposta dois";
function listaPerguntas() {
for (var i = 1; i <= totalPerguntas; i++) {
var frasePergunta = perguntas[i];
var fraseResposta = respostas[i];
document.write("<div id='classPergunta'><div id='frasePergunta'><h2>" + frasePergunta + "</h2></div>" + "<br>" + "<div id='fraseResposta'><h4>" + fraseResposta + "</h4></div></div>" + "<br>");
}
}
function mudarEstado() {
document.getElementById("classPergunta").style.display = "block";
}
document.write(listaPerguntas())
document.write("<br><br><button type='button' onclick='mudarEstado('perguntas[i].respostas[i]')' >Next</button>");
Basically, it gets the Array
and returns the questions stored in them at the click of the button. What I'm looking for is a solution to make a set of questions and answers that to the click it to advance to the next question and hide the other divs
so that it is applied the TWO ARRAYS
, I found a code that basically does which I would like, but a bit different and just with an array, so I could not proceed. I accept constructive criticism because I am training!