i have created checkboxes using for loop. now i want to get the value from checkboxes if its tick or not. if checkboxes is tick then that particular checkbox label must be pass to another jsp page. that's that's the thing i'm trying to do but not getting how to do properly.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1><center>REGISTER FORM</center></h1>
<%
String[] stArray=new String[40];
ArrayList ar = new ArrayList();
int idcounter = 0;
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/registerdb", "root", "");
PreparedStatement ps = con.prepareStatement("select leave_types from leaves");
ResultSet rs = ps.executeQuery();
while(rs.next())
{
String array_value = rs.getString("leave_types");
ar.add(array_value);
}
// out.println(ar);
request.setAttribute("LEV_ARRAY", ar);
}
catch(Exception e)
{
out.println(e);
}
%>
<form action = "insertdata.jsp" name="myform" method="post">
<%
for(int i = 0; i<ar.size(); i++)
{
out.println(ar.get(i));
%>
<input id ="<%=idcounter%>" type="checkbox" name = "" value="" />
<%
idcounter++;
}
// String[] selectedCheckboxes = request.getParameterValues("selected");
%>
<center><button type= "submit" name="action">SIGN UP</button></center>
</form>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire