here is my code the modal does not display. I want to add all of these attributes(total_cost, J, D, E) on my modal form. It's like generating a report.
I want to use the same button for calling calcost function and display modal.
function CalCost(a) {
var area = a;
var J = 0;
var D = 0;
var E = 0;
var P = 0;
var Total_Cost = 0;
var max = 100;
if (a == 1) {
J = 4250;
D = 1275;
E = 1700;
P = 6375;
Total_Cost = J + D + E + P;
} else if (a > 1) {
var JD = 10 * a;
J = JD * max;
var DD = 3 * a;
D = DD * max;
var ED = 4 * a;
E = ED * max;
var PD = 15 * a;
P = PD * max;
Total_Cost = J + D + E + P;
// window.prompt(" Cost : ",Total_Cost);
document.getElementById('calValue').innerHTML = Total_Cost;
}
}
CalCost(2)
// Get the modal
var modal = document.getElementById('myModal');
// Get the button that opens the modal
var btn = document.getElementById("Cost");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks on the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
.modal {
display: none;
/* Hidden by default */
position: fixed;
/* Stay in place */
z-index: 1;
/* Sit on top */
left: 0;
top: 0;
width: 100%;
/* Full width */
height: 100%;
/* Full height */
overflow: auto;
/* Enable scroll if needed */
background-color: rgb(0, 0, 0);
/* Fallback color */
background-color: rgba(0, 0, 0, 0.4);
/* Black w/ opacity */
}
<div id="map" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'" style="overflow:hidden;">
<div id="myModal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<p id='calValue'></p>
</div>
</div>
</div>