I have a main.php page with some checkboxes and a textbox, what I am trying to achieve is on selecting of "Select All or any of the checkboxes the values should be passed".The checkbox change function should trigger and post the data to ajaxData.php. The Ajaxdata.php should return the respective team members name back to the main.php page and display the fname values in a textbox.
The problem right now is nothing happens on click on any of the checkboxes
My main.php page is below
Select All <input type="checkbox" name="select_all" id="select_all" value="1">
Pythons<input type="checkbox" name="select[]" id="team" value="Pythons">
Wipers <input type="checkbox" name="select[]" id="team" value="Wipers">
<input type="textbox" name="first_name" value="">
<script>
$("#select_all").change(function() {
var select_all = $(this).val();
alert('1');
if(select_all){
$.ajax({
type:'POST',
url:'ajaxData.php',
data:'select_all='+select_all,
success:function(html){
$('#first_name').html(html);
}
});
}else{
//$('#carrier').html('<option value="">Select State First</option>');
}
</script>
ajaxData.php code looks like the following
if(isset($_POST["select_all"]) && !empty($_POST["select_all"])){
$select_sql="SELECT * FROM member WHERE team_id = ".$_POST['select_all']." ORDER BY name ASC";
$result=mysqli_query($con,$select_sql);
$cnt=mysqli_num_rows($result);
if($cnt > 0)
{
while($results=mysqli_fetch_assoc($result))
{
if($results['id'] !=0 )
{
echo $results['fname']
}
}