цикл для каждого элемента:
<?php
$num = $total['num'];
$num -= $off;
if($res['is_buy'] == 1){
foreach ($logs as $val) { ?>
<tr>
<th scope="row"><?=$num?></th>
<td><?=$val['ip']?></td>
<td><?=$val['os']?></td>
<?php if ($val['online'] == 1) { ?>
<td style="color: green;">Онлайн</td> <?php } ?>
<?php if($val['online'] == 0) { ?>
<td style="color: red;">Оффлайн</td> <?php }?>
<?php if($val['disable'] == 0){?>
<form method="POST" action="get.php">
<td><input type="checkbox" id="switch" value="<?=$val['id']?>" name="enable" checked="checked" onchange="enableq(this.value)"><label class="disable" for="switch">Toggle</label></td>
</form>
<?php } if($val['disable'] == 1){ ?>
<form method="POST" action="get.php">
<td><input type="checkbox" id="switch" value="<?=$val['id']?>" name="disable" onchange="disableq(this.value)"/><label class="disable" for="switch">Toggle</label></td>
</form>
<?php }?>
<!--<td><?=downcounter($val['last_update']);?></td> -->
<td><?=$val['hwid']?></td>
<td><a href="/delete.php?del=<?=$val['id']?>" class="btn btn-default">✖</a></td>
</tr>
<?php
$num = $num - 1 ;
}
onchange event:
<script>
function disableq(id){
$.ajax({
method: "POST",
url: 'get.php',
data: ({disable: id}),
success: function(response){
alert("disable");
}
});
window.location.reload();
};
function enableq(id){
$.ajax({
method: "POST",
url: 'get.php',
data: ({enable: id}),
success: function(response){
alert("enable");
}
});
window.location.reload();
};
</script>
при нажатии на чекбокс с номером 1 срабатывает чекбокс под номером 2, хотя если нажимать на чекбокс 2, все работает отлично