[jQuery] checkboxes, array and $.post
Hi,
I have a tabular data I need to be able to delete by selecting
checkboxes, and submitting a form (a .php script then checks which
checkboxes have been submitted, delete by id, return an updated list
of the items injected into the dom).
My problem is that I currently can't manage to gather these checkboxes
values as an array.
Please consider the below code:
$(document).ready(function(){
//submit the form
$("form#form-delete").livequery('submit', function(event){
$("span#wait").html('<img name="wait" src="wait.jpg" />');
$.post("delete.php",{
item_id: $(".item_id").val(),
},function(data){
$("span#wait").html('');
$("div#view-items").html(data);
});
return false;
});
});
And the html:
<input name="item_id" class="item_id" value="1" type="checkbox">
<input name="item_id" class="item_id" value="2" type="checkbox">
<input name="item_id" class="item_id" value="3" type="checkbox">
<input name="item_id" class="item_id" value="4" type="checkbox">
//etc.
What would be the ideal jQuery way to handle checkboxes?
Thanks in advance for your time :)
Regards,
-jj.