When the user selects to delete a department or location, then the system checks against the database to see if that entry is used in other tables (ie personnel assigned to that department) and, if so, should prevent removal.
If it prevents removal I want to have a popup saying: "This department/location can't be removed."
At the moment it is only showing: "Removed" for both elements, the removed ones and the ones that are not being deleted.
How can I make two different responses, one for the removed and one for the non removed?
I have tried the below however it is showing an error on the HTML line 12 which is the css link and I am feeling a bit confused:
Uncaught SyntaxError: missing ) after argument list.
<link rel="stylesheet" type="text/css" href="css/style.css">
What I have tried:
function toggleConfirmDep(message, func) {
if (!event) var event = window.event;
event.cancelBubble = true;
if (event.stopPropagation) event.stopPropagation();
employeeID = $(event.target).closest(".buttons").siblings("form").find("#id").text();
if ($('#confirmDep').css('display') == "none") {
$('#confirmDep').show()
$('#depQuestion').show()
$('#depResponse').hide()
let addOrRemove = capitalizeFirstLetter(message.split(" ")[0])
addOrRemove == "Add" ? addOrRemove += "ed" : addOrRemove += "d"
$('#depMessage').text(message)
$('#depButton').attr('onClick', `
${func.toString()};
$('#depQuestion').hide()
$('#depResponse').show()
if (event.cancelBubble == true) {
$('#depResponseMessage').text('${addOrRemove}');
} else if (event.cancelBubble == false) {
$('#depResponseMessage').text('This department can't be removed.');
} else {
$('#depResponseMessage').text('${addOrRemove}');
}
setTimeout(function(){
$('#confirmDep').hide();
$('#profilePage').hide();
window. location. reload(1);
}, 1500);
`)
} else {
$('#confirmDep').css('display', 'none')
}
}
<div class="modal" id="removeDepartmentOverlay">
<div class="addDepLoc">
<div class="row profileRow">
<h3 style="display: inline">Department:</h3>
<select id="removeDepartmentDepartment" style="display: inline; float: right;"></select>
</div>
<br>
<br>
<div class="row d-flex align-items-center justify-content-center pt-3" id="removeDepLocBtn">
<div class="col d-flex justify-content-center">
<button class="button buttonClose" style="display: inline; float: left;" onclick="toggleRemoveDepartment()"></button>
</div>
<div class="col d-flex justify-content-center">
<div class="btn btn-xs btn-primary5" id="confirmButton" style="display: inline; float: right;" onclick="toggleConfirmDep('Remove', 'removeDepartment()')">^__i class="fa fa-check-circle fa-xs" style="font-size: 1em" data-toggle="modal"></div>
</div>
</div>
</div>
</div>