我有一個提交複選框值的表單。提交之前,顯示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";
}
}
}
?>
你在無限循環 - 調用同一個功能再次只會讓你回到同一個地方。然後你需要調用一個不同的函數,或者將一個參數傳遞給那個告訴自己用戶點擊好的函數,所以現在只需提交 –