1

i have a table fetching data in ajax. so i want get some value return values. mainly i need check box checked count in server side data. i have try many more time. sorry i have no idea how to explain this. I'm New web development.please check my code here

this is my firt html code

<div id="image_data"> </div>
  <script>
  fetch_data();
  function fetch_data()
 {
  var action = "fetch";
  $.ajax({
   url:"get.php",
   method:"POST",
   data:{action:action},
   success:function(data)
   {
    $('#image_data').html(data);
   }
  })
 }

$(document).ready(function(){

 $(":checkbox").change(function() {
        if(this.checked) {
var numberOfChecked = $('input:checkbox:checked').length;
             alert(numberOfChecked) ;
        }

    });
});
</script>

server side script

if(isset($_POST["action"])){
 // fetch data in mysql 

   $output = '
   <table class="table table-bordered table-striped">  
    <tr>
     <th>name</th>
     <th>checkbox</th>
     <th>Change</th>
     <th>Remove</th>
    </tr>
  ';
  while($row = mysqli_fetch_array($result))
  {
   $output .= '

    <tr>
     <td>'.$row["SliderId"].'</td>
     <td>'.$row["Name"].' </td>
     <td><input type="checkbox" name="vehicle" value="abc" id="'.$row["SliderId"].'"></td>
     <td><button type="button" name="update" class="btn btn-warning bt-xs update" id="'.$row["SliderId"].'">Change</button></td>
     <td><button type="button" name="delete" class="btn btn-danger bt-xs delete" id="'.$row["SliderId"].'">Remove</button></td>
    </tr>
   ';
  }
  $output .= '</table>';
  echo $output;
 }

when i have click checkbox. i want alert check box checked count.

safvan saf
  • 43
  • 7
  • 3
    `$(document).ready(function(){ $(document).ready(function(){ …` - what is this? I am not sure if that even works, and it makes no sense to begin with. – 04FS Oct 15 '19 at 12:39
  • @04FS sorry i made my mistake i corrected this . – safvan saf Oct 15 '19 at 14:08

0 Answers0