Hi-
I have a JSP page that dynamically generates x number of questions and responses from a database broken into six different categories, also determined by the database. The ability to save the form at any time and come back to it is available, but Submit can only be selected when all of the questions have been answered. How would I go about this. Below is the JSP code for the questions and responses.
Thank you in advance very much!!
<%
String categoryLetter;
for (int i=2; i <= 7; i++){
%>
<div id="page<%=i%>" class="page">
<%
switch(i){
case 2:
categoryLetter = "J";
break;
case 3:
categoryLetter = "G";
break;
case 4:
categoryLetter = "S";
break;
case 5:
categoryLetter = "C";
break;
case 6:
categoryLetter = "D";
break;
case 7:
categoryLetter = "L";
break;
default:
categoryLetter = "";
}
String categoryTitle = "";
String nextBtn = "";
if (categoryLetter == "J"){
categoryTitle = "Jurisdiction / Community";
nextBtn = "page3";
}
if (categoryLetter == "G"){
categoryTitle = "Presence / Membership";
nextBtn = "page4";
}
if (categoryLetter == "S"){
categoryTitle = "Activity in the Schools";
nextBtn = "page5";
}
if (categoryLetter == "C"){
categoryTitle = "Activity in the Community";
nextBtn = "page6";
}
if (categoryLetter == "D"){
categoryTitle = "Gangs and Drugs";
nextBtn = "page7";
}
if (categoryLetter == "L"){
categoryTitle = "Gangs in the Legal System";
nextBtn = "page1";
}
%>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td width="100%" height="38" class="pageName"><strong><%=categoryTitle%></strong></td>
</tr>
</table>
<table width="600">
<tr>
<td style="padding-left:0px;">
<ol>
<%
questionArrayList = CGAAsmntController.getAllQuestions(categoryLetter);
String isChecked = "";
for(Question curQ : questionArrayList){
responseArrayList=curQ.getResponses();
%>
<li><%=curQ.getQuestionText()%><br />
<% for(ResponseChoice curResponse : responseArrayList){
if(responseHashMap.containsKey(curResponse.getResponseChoiceId())){
isChecked = "checked=\"checked\"";
if(curQ.getQuestionType().getCode()=='R'){
isChecked = "checked";
}
}
else isChecked = "";
if(curQ.getQuestionType().getCode()=='C'){
%>
<input type="checkbox" <%=isChecked %> name="<%=curQ.getQuestionId() + curResponse.getResponseChoiceLetter()%>" value="<%=curQ.getQuestionId() + curResponse.getResponseChoiceLetter()%>" />
<%
}
else if(curQ.getQuestionType().getCode()=='R'){
%>
<input type="radio" <%=isChecked %> name="<%=curQ.getQuestionId()%>" value="<%=curResponse.getResponseChoiceLetter()%>" />
<%
}
out.println(curResponse.getResponseChoiceText() + "<br />");
}
}
%>
</li>
</ol>
</td>
</tr>
<tr>
<td align="right" style="background-color:#cccccc; padding:6px;">
<input type="submit" value="Save" class="asmntButton" />
<input type="button" class="asmntButton" value="Next »" onKlick="showLayer('<%=nextBtn%>');self.location.hash='top';" />
</td>
</tr>
</table>
</div>