Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a 10 checkboxes, when i want to delete the appropriate record I use to select one or more checkbox. All the checkbox nams are array. I'm properly getting the values from the html page to jquery function. After that i pushed all the checked boxes into the array created in the jQuery function. But i'm not able to sent the values from this jquery function to the ajax php function. May be the way i'm trying will be wrong. Please check out my code below.

 function BulkDelete()// jQuery Function
  {
  var Selected = new Array();
  jQuery("input[name='chec[]']:checked").each(function(){
    Selected.push(jQuery(this).val());
  });

    jQuery.ajax({
    url:"<?php echo admin_url( 'admin-ajax.php' ); ?>",
    type:"POST",
    data:"action=doctor_management_add_dept&id="+ Selected +"&task=bulkdelete",
    success:function(data){jQuery("#msg").html("<div id='message'>"+data+"</div>");}
    });


  }

function doctor_management_add_dept() // PHP function
{
if($_POST['task']=="bulkdelete")
{
$ars[] = $_POST['id'];
echo count($ars);
}
}

I'm not getting any error. But the same time it's always returning 1.

share|improve this question
at a time it will always return 1. – fabrik Mar 21 '11 at 12:34

1 Answer

up vote 2 down vote accepted

You may want to serialize your form data, then pass a whole one to your PHP script. In this case, you'll be able to tell how many rows affected.

share|improve this answer
ok.. Lets try.. – Mayilarun Mar 21 '11 at 12:43
The array values are coming properly. When receiving the array value in the php end, it's already in serialized form like 1,2,3,4,5..etc.. So i just used the explode function.. Thank you all for your reply. – Mayilarun Mar 21 '11 at 13:15
You're welcome. Would you accept my answer as correct, please? Thank you :) – fabrik Mar 21 '11 at 13:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.