Hello
I am having a problem with checkboxes in
JSP. I am displaying the checkboxes on one Jsp page.The number of checkboxes are not fixed they come from the database entries. When the user ticks on some checkboxes and clicks on the "BURROW" button, control is transferred to the next JSP page. where i can get the values of the ticked checkboxes. but the problem is that i want to restrict the user to tick only two checkboxes. How do i perform the validation in the second JSP page. I can get the number of checkboxes and pass the number to the next JSP page ..is there any mean by which i can use the isChecked() function to verify the checkbox? I have appended the code below ...Neglect the initial part ..just see the FORM part .
<%@ page language="java" import="java.sql.*"%>
<jsp:useBean id="login" class="WebSphereSamples.donttouchthis.Loginclass" scope="session" />
<jsp:useBean id="allow" class="WebSphereSamples.donttouchthis.Borrow" />
<html>
<body>
<%
String thisuser= good.getUser();%>
<% boolean check= good.getGrant();%>
<%! ResultSet res;%>
<% if(check)
{ %>
<% String author=request.getParameter("aname");%>
<%res= allow.getAuthorBooks(author);%>
<b> The books written by </b><font color="pink" size=5><%= author%></font><b> are</b>
<br><br>
<form method="POST" action="Authornext.jsp">
<% int i=0;%>
<% while(res.next())
{
%>
<input type="checkbox" name="<%= i%>" value="<%= res.getString(1)%>"><%= res.getString(1)%><br>
<% i=i+1;
} %>
<br>
<input type="hidden" name="hide" value="<%= i%>" >
<input type="submit" value="Borrow">
<br><br>
<b>Tick the Books you want to borrow</b><br>
<b> Note: </b> you can have atmost 2 books only<br>
</form>
<% }
else
{
response.sendRedirect("Relogin.jsp");
}
%>
</body>
</html>