• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

delete records

 
jyotsana dang
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a link to the deletion page in jsp..in whcih the first 5 records that have been stored by the user are shown..and a checkbox besides each..
on checking the box/ boxes and on clicking the delete button the records get deleted..
how do we implement this thing with JSP.
 
Praful Thakare
Ranch Hand
Posts: 642
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jyotsana,
Check out if follwing example helps you,

here I go......
give same name to all your checkbox and value as primary key of record to be deleted...
say I have an record identified by rollno ,so while displaying record I will use following code...
.....
....//select statement and all...
while(rs.next())
{
out.pritnln("<tr><td><input type=checkbox name=deletedRec value="+rs.getString("rollno")+........."</td></tr> ) ;

}
...
...

so In your example you will get 5 check box,all with name deleteRec.but different values...
now when you click on delete button,all selected check boxs value will be added to request,which can be collected as
String ids[]=request.getParameterValeus("deleteRec");

now using this string array you can construct query as
delete from soNso where rollno in(ids from array);
Hope this helps
Cheers
Praful
[ March 01, 2004: Message edited by: Praful Thakare ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic