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.