It's not a secret anymore!
The moose likes Servlets and the fly likes Inserting multiple checkbox values into a table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Inserting multiple checkbox values into a table" Watch "Inserting multiple checkbox values into a table" New topic

Inserting multiple checkbox values into a table


Joined: Mar 30, 2001
Posts: 8
I am working on a JSP Page which is required to insert record into two tables simultaneously.This page allows the user to add a grp and grant access rights to applications for that particular grp code.
This page also has checkboxes for each application that i am listing on the page. How do i write an insert query which allows me to insert the names of those applications into the table which are checked and also the group code.There are two tables and both the tables are linked using the group code.
k b

Joined: Feb 01, 2001
Posts: 22
You can do like this:--
Let 1st Jsp ( having grp code and applications) do a submit to another Jsp say controller.jsp.

<form name="1stjsp" action="controller.jsp" method="POST">
In controller.jsp
You can retrieve those parameters using
request.getParameter(), request.getParameterNames() ( This is helpful when we have checkboxes and depends how you have coded the names for them).
Then do JDBC connection and write/insert into tables.
Finally when you are done we can forward back to the 1st page or another page using jsp forward tag.
<jsp:forward page="someother.jsp" />
Hope this helps.

Raja Shekhar
Ranch Hand

Joined: Apr 02, 2001
Posts: 49
hi J-Shree
just try this...
Store the name of the group in the Value atrribute of the
Check Box..

and Check whether check box is Checked /not..
if (check != null)
then just insert...
and let me know it works..

I agree. Here's the link:
subject: Inserting multiple checkbox values into a table
jQuery in Action, 3rd edition