I am trying to create a jsp page that generates a list of questions. The questions are received from the database correctly and the appropriate div is created. There are 55 questions.
What i want to do is make only the first questionDiv visible and set the rest hidden. Then on the submit button click the current question [1] is hidden and the question [2] is made visible.
Nothing i try in the javascript seems to have any affect. Can someone please point me in the right direction?
<div id="questionContainer">
<% for (int ques = 1; ques < 56; ques++) {
out.println("<div id ='question" + ques + "' name='question" + ques + "'class='questionVisible'>");
out.println("<h2 class='page-header'>Question" + ques + "</h2>");
if (iterate.hasNext()) {
//out.println(row[0]);
//out.println(row[1]);
//out.println(row[0]);
String[] row = (String[]) iterate.next();
if (row[0].equals("1")) {
out.println("<p id='question'>" + row[1] + "</p><br/>");
out.println("<p id='ansA'><input type='radio' name='answer" + ques + "' value='A' checked>" + row[2] + "</p>");
out.println("<p id='ansA'><input type='radio' name='answer" + ques + "' value='B' checked>" + row[3] + "</p>");
out.println("<p id='ansA'><input type='radio' name='answer" + ques + "' value='C' checked>" + row[4] + "</p>");
out.println("<p id='ansA'><input type='radio' name='answer" + ques + "' value='D' checked>" + row[5] + "</p>");
out.println("<button class='btn' id='btnPAQues" + ques + "' type='button' name='btnPAQues" + ques + "' onclick='onSubmitBtn();'>Submit</button>");
} else if (row[0].equals("2")) {
out.println("<p id='question'>" + row[1] + "</p><br/>");
out.println("<p id='ansA'><input type='radio' name='answer" + ques + "' value='A' checked>" + row[2] + "</p>");
out.println("<p id='ansA'><input type='radio' name='answer" + ques + "' value='B' checked>" + row[3] + "</p>");
out.println("<p id='ansA'><input type='radio' name='answer" + ques + "' value='C' checked>" + row[4] + "</p>");
out.println("<p id='ansA'><input type='radio' name='answer" + ques + "' value='D' checked>" + row[5] + "</p>");
out.println("<p id='ansA'><input type='radio' name='answer" + ques + "' value='E' checked>" + row[6] + "</p>");
out.println("<button class='btn' id='btnPAQues' type='submit' name='submit' onsubmit='onSubmitBtn'>Submit</button>");
} else if (row[0].equals("3")) {
out.println("<p id='question'>" + row[1] + "</p><br/>");
out.println("Answer: <p id='ansA'><input type='text' name='answer" + ques + "'</p><br/><br/>");
out.println("<button class='btn' id='btnPAQues' type='submit' name='submit' onsubmit='onSubmitBtn'>Submit</button>");
}
}
out.println("</div>");
}
%>
</div>
<script>
for(int x= 2; x <56; x++)
{
document.getElementById("question"+x).style.visibility = "questionHidden;";
}
document.getElementById("btnPAQues1").onclick = onSubmitBtn();
function onSubmitBtn() {
document.getElementById("question1").style.visibility = "hidden;";
}
</script>