我不知道如何传递复选框的选定值。任何帮助或建议都会对我有很大帮助。
到目前为止,这是我的代码,我一直在传递复选框的值
index.php
<table>
<?php
foreach($response as $item){
echo '<tr><td><input type="checkbox" value="' .$item['id']. '"></td><td>' . $item['name'] . '</td></tr>';
}
?>
</table>
<button type="button" class="btnadd">AddSelected</button>
<script type="text/javascript">
$(function() {
$('.btnadd').click(function() {
$.ajax({
url: 'process.php',
type: 'post',
data: { }, // what should I put here to pass the value of checked checkboxes
success: function(data) {}
});
});
});
</script>
process.php
<?php
$array_ids = $_POST['ids']; // this will retrieve the id's
?>