-2
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, he takes the Array
and returns the questions stored in them at the click of the button. What I’m looking for is a solution to ask a set of questions and answers that in the click it moves to the next question and hide the other divs
so that this is applied to the TWO ARRAYS
, I found a code that basically does what I’d like, but a little different and just with an array, so I couldn’t go on. I accept constructive criticism because I’m training !
It did help ! Thank you so much for your contribution and for sharing your criticism with me !
– Elton Miranda