单击另一个按钮后禁用两个按钮
因此,一旦我成功单击“关闭”按钮,我需要能够禁用两个按钮(批准和返回按钮)。谁能帮我吗?代码的第一部分是我需要禁用的按钮。
<div class="text-center ">
<button class="btn m-1 align-items-center btn-success text-center " type="submit" id="approve_button" data-toggle="modal" data-target="#approveModal">Approve</button>
<button class="btn btn-secondary m-1 align-items-center text-center" type="submit" id="return_button" data-toggle="modal" data-target="#returnModal">Return</button>
</div>
<div>
<button class="btn btn-danger m-5 align-items-center text-center" id="reject_button" name="reject_button" data-toggle="modal"data-target="#rejectModal" >Close Task</button>
</div>
<?php
if (isset($_POST["reject-btn"])){
$rejectt = mysqli_real_escape_string($con, $_POST["rejectt"]);
$sql = "UPDATE task SET task_status='closed' WHERE id_task='$rejectt' ";
$result_rej = mysqli_query($con, $sql);
if ($result_rej) {
$_SESSION['success'] = "Task closed";
$_SESSION['text'] = "Task has been closed successfully";
$_SESSION['icon'] = "success";
} else {
$_SESSION['success'] = "Error";
$_SESSION['text'] = "Unknown error, please try again";
$_SESSION['icon'] = "error";
}
}
?>
<?php
if (isset($_SESSION['success']) && $_SESSION['success'] != '') {
?>
<script>
swal({
title: "<?php echo $_SESSION['success']; ?>",
text: "<?php echo $_SESSION['text']; ?>",
icon: "<?php echo $_SESSION['icon']; ?>",
button: "OK";
});
</script>
<?php
unset($_SESSION['success']);
}
?>
so i need to be able to disable two buttons (approve and return button) once i successfully click the close button. can anyone help me? the first part of the code are the buttons i need to disable.
<div class="text-center ">
<button class="btn m-1 align-items-center btn-success text-center " type="submit" id="approve_button" data-toggle="modal" data-target="#approveModal">Approve</button>
<button class="btn btn-secondary m-1 align-items-center text-center" type="submit" id="return_button" data-toggle="modal" data-target="#returnModal">Return</button>
</div>
<div>
<button class="btn btn-danger m-5 align-items-center text-center" id="reject_button" name="reject_button" data-toggle="modal"data-target="#rejectModal" >Close Task</button>
</div>
<?php
if (isset($_POST["reject-btn"])){
$rejectt = mysqli_real_escape_string($con, $_POST["rejectt"]);
$sql = "UPDATE task SET task_status='closed' WHERE id_task='$rejectt' ";
$result_rej = mysqli_query($con, $sql);
if ($result_rej) {
$_SESSION['success'] = "Task closed";
$_SESSION['text'] = "Task has been closed successfully";
$_SESSION['icon'] = "success";
} else {
$_SESSION['success'] = "Error";
$_SESSION['text'] = "Unknown error, please try again";
$_SESSION['icon'] = "error";
}
}
?>
<?php
if (isset($_SESSION['success']) && $_SESSION['success'] != '') {
?>
<script>
swal({
title: "<?php echo $_SESSION['success']; ?>",
text: "<?php echo $_SESSION['text']; ?>",
icon: "<?php echo $_SESSION['icon']; ?>",
button: "OK";
});
</script>
<?php
unset($_SESSION['success']);
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
单击#Reject_button时,您可以将禁用属性添加到按钮中
You can add disabled attribute to buttons when clicked #reject_button by using jQuery
您可以使用普通JavaScript单击#Reject_button时将禁用属性添加到按钮
You can add a disabled attribute to buttons when clicked #reject_button by using normal javascript
您可以使用简单的JS事件处理程序来执行此操作。提供的示例是一种方法。如果将来需要再次启用它们,则需要一个单独的事件处理程序才能删除残疾人属性。
You can do this using a simple JS event handler. The provided example is one way. If you need to enable them again in the future, you'll need a separate event handler to remove the disabled attribute.
如果您需要在Page Refresh之后禁用它们,则可以使用此功能。
但最方便的方法是,您应该尝试将按钮状态保存在数据库中。
If you need them disabled even after page refresh then you can use this.
But most convenient way is you should try to save the button status in database.