aspose file tools*
The moose likes JSP and the fly likes how to delete the row on click of a checkbox instantly ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "how to delete the row on click of a checkbox instantly ?" Watch "how to delete the row on click of a checkbox instantly ?" New topic
Author

how to delete the row on click of a checkbox instantly ?

sanat meher
Greenhorn

Joined: Nov 06, 2008
Posts: 18
Hi all,

Can anybody tell me how to make a row disappear on click of checkbox and clicking or submiting the form.

I have a form which shows the data from a table in the database in tabular fashion(row and columnwise).And corresponding to one column i have associated a checkbox fro each row of the datable.So when i select one or more than one checkbox,and click on the submit button,it will perform some action and display those selected items in the same form or different form.but i click the submit button,then those selected rows are still there and when i refresh the page then only those are getting disappeared.but i want those selected columns to be disappeared instantly on clicking the submit button without refeshing the page repeatedly.
Can anybody tell me how to do the same.

My code is like this:





Regards,
Sanat
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Not a good idea to put all this logic in the view/JSP. You should probably refactor it to a servlet or preferably the model. For what you are trying to do, you can have some javascript code that will execute on the click event of the checkbox, and call your backend method to do the delete.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Soumik Basu
Ranch Hand

Joined: Oct 01, 2007
Posts: 40
I would suggest that you use AJAX.Then you need not have to submit also and get the page refreshed.
All you need to do is learn using AJAX from some tutorials and put your to be shown table in a div tag and on click of the button(which was your submit button previously)call the method written in AJAX and through AJAX call another jsp or servlet where you write the query for deleting the row.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to delete the row on click of a checkbox instantly ?