I have a modal which gets its content dynamically. The content goes to two divisions modal-body and modal-footer.
But the problem is only modal-body is changed dynamically and modal-footer remains the same.
This is the snippet of html code(includes bootstrap classes):
<a href='#' data-toggle='modal' data-target='#removeCandidateModal' onclick="removeCandidate()">Remove</a>
<div class="modal fade" id="removeCandidateModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Remove Candidate</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body" id="remove-candidates-modal-body">
</div>
<div class="modal-footer" id="remove-candidates-modal-footer">
</div>
</div>
</div>
</div>
The javascript part:
function removeCandidate() {
let id="45678";
let name="Bob";
let election_type="BHVC";
document.getElementById('remove-candidates-modal-body').innerHTML = '<p>Are you sure you want to remove the following candidate<br> Candidate Name:' + name +
'<br>Candidate ID:' + id +
'<br>Elections:' + election_type + '</p>';
document.getElementById('remove-candidates-modal-footer').innerHTML = '<div class="modal-footer">' +
'<button type="button" class="btn btn-secondary" data-dismiss="modal">No</button>\n' +
' <button type="button" class="btn btn-primary" onclick=removeCandidateYes("' + id + '")>Yes</button>\n' +
' </div>';
}
The current output is this(it doesnt show the footer elements):
