Jsp-delete checked checkboxes and display UNCHECKED checkboxes in table as well as in store that unchecked checkboxes in ARRAYLIST

Ads
 

Jsp-delete checked checkboxes and display UNCHECKED checkboxes in table as well as in store that unchecked checkboxes in ARRAYLIST

I have a table with about 20rows, which contain a checkbox and a bit of text each. What I'm trying to find a way to do is to have delete button at the bottom of the page.When i clicked on DELETE button, it should delete records of checked checkbox rows. I need to delete all the table rows which contain CHECKED textboxes.and remaining checkboxes should be displayed. And we should keep remaining checkboxes in ARRAYLIST.

I want to delete checked checkboxes.And store all unchecked checkboxes in Arraylist(collection). and print that arraylist.

I've been able to get bits of it to work at various times, but I'm running out of time and I really need help. Any suggestions anyone has would be more than appreciated! Please,Help me Thanks!

View Answers

October 28, 2010 at 12:32 AM

I am not sure that I have clearly understood your question. I think you want to show the records of a table in a form and the checked records are to be deleted from the table after clicking the DELETE button.

If this is your question for this, you can do the following:

  • Create a form that retrieves values from the table. Use form tag and checkbox input. In in each checkbox retrieve the data from table and show. Use the ID (primary key) of the record as the name attribute in checkbox. This will show as many checkboxes as records in your table.
  • Use submit or button to post the form information to page. Check for which ID (primary key) the checkbox is "on" and for which it is null. For "on" checkboxes delete the record and for null add them to ArrayList. Use if-else for this.

    rs = stmt.executeQuery("SELECT emp_id FROM emp");

    while (rs.next) { String checkbox = request.getParameter("emp_id"); if (checkbox == null ) { al.add(Object); } else { stmt1.execute("DELETE emp WHERE empid"+ = empid); } }

I have written this code assuming that it's a part of a file. You will have to create ArrayList, connection, statement, etc. I hope this will help you.


October 28, 2010 at 10:43 AM

Thanks for your valuable reply... But I have a arraylist of records. From that arraylist , if i want to delete some records of table ,then using checkboxes,after checking some of checkboxes, i want to delete selected (checked)checkboxes.And remaining checkboxes should be retained in that arraylist. So, previous arraylist is replace by new arraylist with same name.

Please, can you give me some code.Actually i tried hard to get it.But i am going out of time.So, please help me.

Thanks in advance !!!!!!! :)

Ads









Related Tutorials/Questions & Answers:
how to display selected checkboxes dynamically using jsp
how to display selected checkboxes dynamically using jsp  Hi friends i have a requirement that : in my JSP page i have radio buttons followed by the DB fields..when i click SUBMIT button,if the field(or record
List of checkboxes - JSP-Servlet
with a checkbox against every such time-slot in a JSP page. My requirement is that when one or more checkboxes are checked and the delete button is clicked, then the selected time slots should be deleted. The time slots are getting added in ArrayList
Advertisements
Maintaining States of Selected CheckBoxes in Different Pages using dispaly table in struts2
Maintaining States of Selected CheckBoxes in Different Pages using dispaly table in struts2  Hi, I am working in a Struts 2 project where in the jsp.... Actually my requirement is to select particular checkboxes across different pages
How to add a column with checkboxes for each record in my table in JSP
How to add a column with checkboxes for each record in my table in JSP  ... boxes for each record in my table in JSP? Also, I want to figure out a way that what records the user has checked! If you could give me the answer with an example
The checkboxes tag
In this section, you will learn about checkboxes tag of Spring form tag library
deffernce between checked and unchecked exception in java
deffernce between checked and unchecked exception in java  What is deffernce between checked and unchecked exception in java please explain by example
Updating multiple value depending on checkboxes
Updating multiple value depending on checkboxes  Hi .. I want to Update the multiple values of database using checkboxes and want to set the session for selected checkboxes..? please answer if any one knows as soon as possible
Retriving multiple values of checkboxes in struts
Retriving multiple values of checkboxes in struts  how to retrive multiple values of checkboxes of jsp in action class   JSP Retrieve checkbox values 1)checkbox.jsp: <html> <body> <form method="post
unchecked exception
unchecked exception  What happens if the service method throws an unchecked Exception
JavaScript Array of checkboxes
JavaScript Array of checkboxes   ... that help you in understanding JavaScript Array of checkboxes. For this we...;!document.form1.sex[1].checked){ alert("Please Select Sex"
Delete multiple records with pagination by selecting checkboxes
and then delete it.Can any one please help me.Also i want to keep the checked check...Delete multiple records with pagination by selecting checkboxes  Hi there,I'm working with PHP.I want to delete my database records which
How to execute mysql query based on checkboxes values in java swing application.
How to execute mysql query based on checkboxes values in java swing application.  Hello Sir, I have a java swing application and i have to execute query based on selection of checkboxes.Means I have to to execute
How to execute mysql query based on checkboxes values in java swing application.
How to execute mysql query based on checkboxes values in java swing application.  Hello Sir, I have a java swing application and i have to execute query based on selection of checkboxes.Means I have to to execute
How to execute mysql query based on checkboxes values in java swing application.
How to execute mysql query based on checkboxes values in java swing application.  Hello Sir, I have a java swing application and i have to execute query based on selection of checkboxes.Means I have to to execute
how to update combobx's selected value to database with respect toselected multiple checkboxes
how to update combobx's selected value to database with respect toselected multiple checkboxes   suppose this if form1.jsp in which i am going to display records from database out.println("<tr><td>"+"<input type
want to ask how to update data for runtime selected multiple checkboxes
have checkboxes for each record when I will select more than one checkboxex...); //alert("enter"); if(f1.elements[cnt].checked==true){ values[j]=f1.elements...("<table Id=dataTable border=1 bordercolor=#8080cc bordercolorlight=#8080c0
Making Exceptions Unchecked - java tutorial,java tutorials
Checked and Unchecked Exception In this section, you will learn Checked and Unchecked Exceptions in java and how to handle it. The Exception is a condition... below types of built-in exception in java : 1. Unchecked Exception 2. Checked
Displaying checked checkbox in same page as well as print on another page ....also add next pages cheches checkbox into previous list
Displaying checked checkbox in same page as well as print on another page... same checkboxes. So, from your above code, i can display selected checkbox on same..., it does not display previous page's selected checkboxes. So, i want such output
dispalying arraylist values in table form
dispalying arraylist values in table form  My result is in arraylist and i want to display it in table form using iterator tag
checked and uncheked exception
checked and uncheked exception  please give some information about checked and unchecked exception
cannot display an arrayList in JSP
cannot display an arrayList in JSP  Hello, My bean is called Zone, i... a servlet to a jsp. In servlet.class print("List result = dao.getListZone...=""; int count=0; List viewList = new ArrayList(); Iterator viewItr; Iterator itr
JSP - Checkbox remain checked although checked values should depend on values stored in a stateful session bean
JSP - Checkbox remain checked although checked values should depend on values.... There are 3 JSP pages, shop1.jsp , shop2.jsp and shop3.jsp where each of these pages... displays all of the items selected. The selection of items is made using checkboxes
Addin checkbox to table
Addin checkbox to table  how to add checkboxes in JTable
search an element in arraylist and display in jsp page
search an element in arraylist and display in jsp page  Hello Can anyone help how to take input from user from a jsp page to search for a substing in arraylist in java class and display the list in jsp page Thanks
Retrive values from an arraylist and display in a jsp?
Retrive values from an arraylist and display in a jsp?  Hi, I need help in jsp to display values of an ArrayList in jsp. There is a java file containing a method which is returning an ArrayList. I want to display the records
To store value in session & display it
To store value in session & display it  Hello..I m trying to run the following code which will store the session of a book selected on click... Help me in this.. This is the JSP Page <html> <head>
JSP Delete Record From Table Using MySQL
JSP Delete Record From Table Using MySQL This tutorial explains you that how to write a JSP for deleting a record from database table. In this section you.... In this tutorial you will learn that how to delete a record of a database table in JSP
how to use stringtokenizer on table? and display in table format.
display result in row format  how to use stringtokenizer on table? and display in table format
Retrive values from an arraylist and display in a jsp?
Retrive values from an arraylist and display in a jsp?  Hi, I need help in jsp to display values of an ArrayList in jsp. There is a java file containing a method which is returning an ArrayList. I want to display the records
Display items in table
Display items in table  I have a listbox which has some items... in a table. I want these items to be displayed in the table to be unique...i.e. if I reselect those same items they should not be displayed in the table and may
how to use stringtokenizer on table? and display in table format.
how to use stringtokenizer on table? and display in table format.  table is retrieved from mysql database and each row contains data like(java,c,c++,.net

Ads