Why is only one value of the \"db\" checkbox values array being sent to the server side script?
JQUERY:
$(\".db\").live(\"change\",
I agree with @jjclarkson. Just to add, instead of pushing your ids to an array, you can use $.map:
$(".db").live("change", function() {
$(this).add($(this).next("label")).add($(this).next().next("br")).remove().insertAfter(".db:last + label + br");
var url = "myurl.php";
var db = $('.db:checked').map(function(i,n) {
return $(n).val();
}).get(); //get converts it to an array
if(db.length == 0) {
db = "none";
}
$.post(url, {'db[]': db}, function(response) {
$("#dbdisplay").html(response);
});
return true;
});
$('input[name="mycheckboxes"]:checked').map(function(){
return $(this).val();
}).get().join(",");
then explode in PHP
$mycheckboxes = explode(',',$_GET['mycheckboxes']);
You need to have the square brackets to specify an array [] on the submitted variable name.
{'db[]': db}
$(".db").live("change", function() {
$(this).add($(this).next("label")).add($(this).next().next("br")).remove().insertAfter(".db:last + label + br");
var url = "myurl.php";
var db = [];
$.each($('.db:checked'), function() {
db.push($(this).val());
});
if(db.length == 0) {
db = "none";
}
$.post(url, {'db[]': db}, function(response) {
$("#dbdisplay").html(response);
});
return true;
});
var checkeditems = $('input:checkbox[name="review[]"]:checked')
.map(function() { return $(this).val() })
.get()
.join(",");
$.ajax({
type: "POST",
url: "/index.php/openItems/",
data: "ids=" + checkeditems,
success: function(msg) { $(".mainContainer").html(msg); }
});