Getting all selected checkboxes values using ajax and jsp/servlets?
- by A.S al-shammari
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 .