我有一个提交复选框值的表单。提交之前,显示Bootbox确认对话框。但是,点击“是”时,表单不会提交。我该如何解决它?我的代码是:如何使用bootbox确认提交表单
$('#student_delete_form').submit(function(e) {
var currentForm = this;
e.preventDefault();
bootbox.confirm("Are you sure?", function(result) {
if (result) {
currentForm.submit();
}
});
});
<form id="student_delete_form" name="" action="#" method="post"></form>
<input type='submit' value='Delete' name='delete' form="student_delete_form"><br>
<?php $studentArray = array(3, 4, 5, 6); ?>
<?php foreach ($studentArray as $key => $value): ?>
<input name="checkbox[]" type="checkbox" value="<?php echo $value;?>" form="student_delete_form">
<?php echo $value;?><br>
<?php endforeach; ?>
<?php
if(isset($_POST['delete'])){
$chk=isset($_POST['checkbox'])? $_POST['checkbox']:"";
if ($chk != "")
{
$chk_array=array_filter($chk);
foreach($chk as $key => $chke)
{
echo "$chke";
}
}
}
?>
你在无限循环 - 调用同一个功能再次只会让你回到同一个地方。然后你需要调用一个不同的函数,或者将一个参数传递给那个告诉自己用户点击好的函数,所以现在只需提交 –