Not sure if it's the *best* way, but it works I'd do something like
var CheckedIDs = []; $("input.item_id").each(function() { if (this.checked) { CheckedIDs.push($(this).attr("value")); } }); if (CheckedIDs.length == 0) { alert("Nothing selected!"); } else { $.post( "delete.php", item_ids: CheckedIDs.join(","), function(data) { //Handle the returned results } } "delete.php" will see a comma delimited string of IDs to delete On Dec 31, 7:11 am, jjshell <blahblahcoui...@gmail.com> wrote: > 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.