Reputation: 203
HTMLs that come from Database are being written to the screen by a for loop. Some of these HTMLs need to be submitted. What is wrong with the code?
<body>
<% int i;
if (books != null) {
for (i = 0; i < books.size(); i++) {
%>
<hr>
<form class ="container" action="jspCheckBox.jsp" method="get" id="<%=i%>">
<%
if (books.get(i).getId() == null) {
out.print("Axtardiginiz melumat tapilmadi");
} else {
out.print(books.get(i).getId());
}
%>
<input type="checkbox" name ="id" value="<%=i%>"> Seç<br>
<input type="submit" style="display:none">
</form>
<input type="submit" form="<%=i%>" value = "Submit">
<%
}
}
%>
<hr>
Upvotes: 0
Views: 563
Reputation: 203
I'm fix it.
<form class ="container" id ="form" action="jspCheckBox.jsp" method="get">
<%
for (i = 0; i < books.size(); i++) {
if (books.get(i).getId() == null) {
out.print("Axtardiginiz melumat tapilmadi");
} else {
out.print(books.get(i).getId());
}
%>
<input type="checkbox" value="<%=i%>" name ="id" > Seç
<%
}
%>
<input type="submit" value = "Selected " >
</form>
Upvotes: 1