<div class="modal" tabindex="-1" role="dialog" id="myModal" data-backdrop="static" data-
keyboard="false">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"id="myModalTitle">Alias Name</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true"&rt;×<&rt;
</button>
</div>
<div class="modal-body" id="myModalContent">
<p>Do you want your First Name as Alias Name</p>
</div>
<div class="modal-footer"&rt;
<button id="myModalButtonYes" type="button" class="btn btn-primary" data-
dismiss="modal"&rt;Yes</button>
<button id="myModalButtonNo" type="button" class="btn btn-secondary" data-
dismiss="modal" &rt;No</button>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function ()
{
$('#myModalTitle').text('Duplicate Patient');
$('#myModalContent').text('A patient already exists with the same name and
birthdate. Do you want to continue?');
const btn = document.getElementById("myModalButtonNo")
btn.addEventListener("click", DuplicateName())
$('#myModal').modal('toggle');
});
I needed to execute different functions when the modal Ok button is clicked in various situations. btn.addEventListener("click", DuplicateName()) and document.getElementById("myModalButtonNo").onclick = DuplicateName() were unsuccessful in this case.
I appreciate any suggestions you have on this matter.