Getting all selected checkboxes values using ajax and jsp/servlets?

Posted by A.S al-shammari on Stack Overflow See other posts from Stack Overflow or by A.S al-shammari
Published on 2010-04-22T05:16:12Z Indexed on 2010/04/22 5:23 UTC
Read the original article Hit count: 251

Filed under:
|
|
|

Hi.. I'm developing a jsp/serlvet application. I have a page with a list of inputs as checkboxes . I want to send values of selected buttons to a servlet using ajax/jquery. In the servlet , I want to extract these values and use them .
for example:

  • The user checks some checkboxes , for example, list of messages.
  • He/She presses Delete Link to delete selected messages.

I searched and found something like this :

$("#inboxDeleteSelected").click(function(){
    var data = { 'checkBoxList[]' : []};
    var list=$(":input:checkbox:checked"); // getting all selected checkboxes.
    $(list.each(function() {
       data['checkBoxList[]'].push($(this).val());
    }));
    $.post("servlet?do=deleteSelected",data,function(d){
        // do something here
    });
});

My questions:

  • How can I send selected checkboxes values to a servlet ?
  • How can I extract these values in the servlet ?

Note:

I don't use submit button to submit the selected checkboxes,Indeed I use link/anchor to send those values .

© Stack Overflow or respective owner

Related posts about servlets

Related posts about jsp