This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Servlets and the fly likes checkbox in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "checkbox in jsp" Watch "checkbox in jsp" New topic

checkbox in jsp


Joined: Aug 11, 2001
Posts: 1
hi to all
I provide a number of checkboxes in number of rows.If the user selects several checkbox and clicks on add button which i provide below, then the data on which those he selects the checkboxes must add to the database.This is same as to delete case also.How to send data to the database by selecting more than one checkbox
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

your name doesn't seem to agree with the javaranch guidelines.
please take a moment and re-register after reviewing the guidelines at http:www/
thanks for your cooperation.
- satya

Take a Minute, Donate an Hour, Change a Life
Ranch Hand

Joined: Aug 06, 2001
Posts: 34
<%@ page import="java.util.Vector"%>
<%@ page import="java.util.Enumeration"%>
<%@ page session = "true" %>

Vector userVec=null;
//userVec getting from servlet(somewhereelse) for diaplaying all the records
<title>Testing </title>

//UserSvc is servlet for adding or deleteting the records from table.
<form NAME="admin" action="/UserSvc" METHOD="POST" >
<table width=100% border="1" cellspacing="2" cellpadding="5" >
<th width="20%" >User ID</th>
<th width="20%" >Full Name</th>

for( int i=0,Enumeration e=userVec.elements() ;e.hasMoreElements();i++){
//UserTB is accessor class means ... have setXXX() and getXXX() methods........
UserTB usertb = null;
String userId=null;
String fullName=(String)usertb.getFullName();

String hiddenFieldFullName="fullName"+i;

<td width="4%">
<input type="checkbox" name="USERID" value=<%=userId%> ></td>
<td width="20%" > <%=userId%> </td>
//If U need this value ...req.getPaarameter("fullNameX");//X=0,1,..or ..4
<input type="Hidden" name="<%=hiddenFieldFullName%>" value=<%=fullName%> > </td>
<td width="20%"> <%=fullName%> </td>
<input type="submit" name="AddNew" value="Add New">
<input type="submit" name="DeleteChecked">
//UserSvc servlet file
public class RoleSvcServlet extends HttpServlet{
//Main(service) function

public void service(HttpServletRequest req, HttpServletResponse res)throws IOException,ServletException
//This list(userId[]) getting from jsp
String[] userId= req.getParameterValues("USERID");
//This is for adding the new record
String addNew=(String)req.getParameter("AddNew");
String fullName=null;
String fullNameValue=null;
for(int i=0;i<userId.length;i++){
String fullName=null;
String fullNameValue=null;

for(int i=0;i<userId.length;i++){
//Ending delete

Dil se....,<BR>Dayanand<BR>0065-8839071(off)<BR>0065-7547034(Res0
I agree. Here's the link:
subject: checkbox in jsp
It's not a secret anymore!