gpt4 book ai didi

javascript - 如何在提交之前延迟输入提交按钮几秒钟

转载 作者:行者123 更新时间:2023-12-03 01:22:52 25 4
gpt4 key购买 nike

我有一个模式,其中包含学生将选择的目的列表,单击确认后它会自动重定向成功消息页面,有没有办法延迟我想向学生显示的输入类型提交他在几秒钟内选择什么并重定向到成功消息。

这里是模态形式:

<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-notify modal-info modal-sm"role="document">
<div class="modal-content">
<div class="modal-header d-flex justify-content-center">
<p class="heading">Your Purpose ?</p>
</div>
<div class="modal-body">
<form method="post" action="index111.php">

<div class="custom-control custom-radio">
<input type="radio" class="custom-control-input" id="purpose1" name="purpose" value="Assignment">
<label class="custom-control-label" for="purpose1">Assignment</label>
</div>
<div class="custom-control custom-radio">
<input type="radio" class="custom-control-input" id="purpose2" name="purpose" value="Reading">
<label class="custom-control-label" for="purpose2">Reading</label>
</div>
<div class="custom-control custom-radio">
<input type="radio" class="custom-control-input" id="purpose3" name="purpose" value="Research">
<label class="custom-control-label" for="purpose3">Research</label>
</div>
<div class="modal-footer flex-center">

<button type="submit" name="submit02" id="modal_button" class="btn btn-primary">Confirm</button>
</div>
</form>
</div>
</div>
</div>

这是index111.php中的代码:

<?php
session_start();
include_once ('connection.php');
if(isset($_POST['submit02']))
{
$time=date("H:i:s");
$purpose = $_POST['purpose'];
$sql = mysqli_query($conn,"select * from student_att order by number DESC limit 1");
while( $row = mysqli_fetch_array($sql)) {
$rfid=$row['rfid_num'];
$InsertSql = "Update student_att set purpose = '$purpose' , timein = '$time' where rfid_num='$rfid' order by number DESC limit 1";
$res = mysqli_query($conn, $InsertSql);
header("location:valid.php");
}
}
?>

valid.php是成功信息,希望你能帮助我。谢谢

最佳答案

您可以使用 jquery 函数来完成此操作,如下所示:

$('#myform').submit(function(event) {
var form = this;
event.preventDefault();
$('.modal-body').append('You chose an option: '+$("input[name=purpose]:checked").val());
setTimeout( function () {
form.submit();
}, 5000);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-notify modal-info modal-sm"role="document">
<div class="modal-content">
<div class="modal-header d-flex justify-content-center">
<p class="heading">Your Purpose ?</p>
</div>
<div class="modal-body">
<form method="post" action="index111.php" id="myform">

<div class="custom-control custom-radio">
<input type="radio" class="custom-control-input" id="purpose1" name="purpose" value="Assignment">
<label class="custom-control-label" for="purpose1">Assignment</label>
</div>
<div class="custom-control custom-radio">
<input type="radio" class="custom-control-input" id="purpose2" name="purpose" value="Reading">
<label class="custom-control-label" for="purpose2">Reading</label>
</div>
<div class="custom-control custom-radio">
<input type="radio" class="custom-control-input" id="purpose3" name="purpose" value="Research">
<label class="custom-control-label" for="purpose3">Research</label>
</div>
<div class="modal-footer flex-center">

<button type="submit" name="submit02" id="modal_button" class="btn btn-primary">Confirm</button>
</div>
</form>
</div>
</div>
</div>

关于javascript - 如何在提交之前延迟输入提交按钮几秒钟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51688103/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com