Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

checkboxes and deleting records  RSS feed

 
clyde melly
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a jsp page which contains multiple checkboxes.If i select some checkboxes then the relevant rows should be deleted from the database.How do i go about it.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Clyde,

What part have you done so far?
What are you stuck on?

People in a forum are usually happy, often anxious, to help a person who's hung up on a particular detail. Teaching someone all the fundementals of server side Java and JDBC is a little beyond the scope of a use list or forum.

Luckily, there are lots and lots of tutorials on JSP, Servlets, JDBC, and web programming in general.
http://www.google.com/search?hl=en&q=JDBC+TUTORIAL&btnG=Google+Search
http://www.google.com/search?hl=en&lr=&q=JSP+TUTORIAL&btnG=Search

Good-Luck
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
quite right Ben.
request.getParameterValues() is a hint for you, Clyde.
 
clyde melly
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K Ben i had to mention the part I'm stuck on.How do i identify the checkboxes which r checked and then corresponding to it I have a id which is unique in the database.The moment i click submit i need to pass those ids into a delete query which wud delete the records from the database.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a checkbox is checked, request.getParameter("checkbox_name") will return either "on" if you didn't specify a value or, if you did, whatever the value was that you set.

If the checkbox isn't checked, request.getParameter("checkbox_name") will return null.

Also, if it isn't checked, the browser won't send the param name up at all.
It will be as if the checkbox never existed on the page.
 
sunitha reghu
Ranch Hand
Posts: 937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Cylde,
Make the check boxes as in array
so the value of the checkbox starts from 0 to end of array.

Then when in the server side

String [] toDelete= request.getParameterValues(" whatEverName");
Then you can check if there is a 0 value then it means record number 1.

If there is 4 value then record number 5. Hope you got my logic
 
clyde melly
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx ben n sunitha.sunitha is there any working example where in i can check to just get an idea abt the implementation.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://pdf.coreservlets.com
Has a chapter that covers all the elements of HTML forms.
There are downloadable examples too.

The whole book is available for free in PDF form.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!