У меня есть вопрос1, в котором запрашивается дата запроса и кнопка, вызывающая функцию для проверки даты.
Ниже этот бесклассовый div есть и другие с class="question", но я не помещал его здесь для простоты.
Код: Выделить всё
var respostas = {}; //variable to save the responses.
//Function that validates the date of the query, which must be equal to or earlier than the current day.
function validarAvaliacao () {
var dataAvaliacaoInput = document.getElementById('dataAvaliacao');
var dataAvaliacao = new Date(dataAvaliacaoInput.value);
var hoje = new Date();
//Translation of 'hoje' = today
//if to return an error if the date exceeds the current day.
if (dataAvaliacao > hoje) {
alert("A data da avaliação deve ser igual ou anterio à data de hoje!");
return;
}
//If the date is valid, go ahead
guardarResposta('dataAvaliacao');
mostrarProxima('perguntaNome');
}
//function to save the response in the variable seen at the beginning of the code
function guardarResposta (idResposta) {
var resposta = document.getElementById(idResposta).value;
respostas[idResposta] = resposta;
var proximaPergunta = 'pergunta' + (parseInt(idResposta.replace('resposta', '')) +1);
mostrarProxima(proximaPergunta);
}
//function that should display the next question
function mostrarProxima (id) {
document.getElementById(id).style.display='block';
console.log('funcionou')
}Код: Выделить всё
@charset "UTF-8";
div.question {
display: none;
}Код: Выделить всё
Data da Avaliação:
Próximo
Qual é o seu nome?
Próximo
Подробнее здесь: https://stackoverflow.com/questions/784 ... ding-style
Мобильная версия