vendredi 1 avril 2016

filtet data by checkbox using jquery ajax mysql and php

i have a group of dynamic checkbox of location

    <?php
        foreach($qry_2 as $v2){

    ?>
    <li class="checkbox">
        <label>
     <input type="checkbox" class="i-check" id="locality" name="locality[]" value="<?php echo $v2['outlet_locality'] ?>"><?php echo $v2['outlet_locality'] ?> <small class="location"><?php echo '('.$v2['outletCount'].')' ?></small>
        </label>
    </li>
<?php
}
?>

and i got aprox 10 input checkbox values i want to filter the content according to the checkbox(multiple select) using jquery and send data to filter.php to retrive as json data

$('input#locality').change(function(){

 var locality = [];
    $(':checkbox:checked').each(function(i){
      locality[i] = $(this).val();

    alert(locality[i])



   $.post("filter.php", {name: locality[i]}, function(data){
       alert(data);
});
   });
});

when i checked the checkbox i got indivisual value not an array,so how can i get the array value of multiple checkbox checked to send to the filter.php




Aucun commentaire:

Enregistrer un commentaire