Good Day,
So I have three pages with the following scripts I would like to disable this button(sign button) along with 4 other buttons eg (add, update, change-status, delete) once the sign button is clicked
Please note the buttons I mentioned before have similar scripts as the sign script below just the actual function that the buttons perform are different for eg the add button would insert a new record, update would update a record etc)
Any assistance would be greatly appreciated.
Script 1 index.php
$(document).on('click','.sign', function(){
var expenditureid = $(this).attr("id");
var btn_action = 'sign';
if(confirm("Are you sure you want to sign this expenditure?"))
{
$.ajax({
url:"expenditure_action.php",
method:"POST",
data:{expenditureid:expenditureid, btn_action:btn_action},
success:function(data)
{
$('#alert_action').fadeIn().html('<div class="alert alert-info">'+data+'</div>');
expendituredataTable.ajax.reload();
}
})
}
else
{
return false;
}
});
Script 2 action.php
if($_POST['btn_action'] == 'sign') {
$signed = "yes";
$query = "
UPDATE expenditure
set checking_officer = :checking_officer,
modified_by = :modified_by,
signed = :signed
WHERE expenditureid = :expenditureid
";
$statement = $connect->prepare($query);
$statement->execute(
array(
':checking_officer' => $_SESSION["user_id"],
':modified_by' => $_SESSION["user_id"],
':signed' => $signed,
':expenditureid' => $_POST["expenditureid"]
)
);
Script 3 fetch.php
$sub_array[] = "<button type='button' name='sign' id='".$row['expenditureid']."' class='btn btn-secondary btn-xs sign'>Sign";
$sub_array[] = "<button type='button' name='delete' id='".$row['expenditureid']."' class='btn btn-danger btn-xs delete'>Delete";
you can use this function
function disable_buttons (buttons) {
buttons.each(function(){
$(this).attr("disabled", "disabled")
})
}