i have created a button which calculates sum value . after calculation i want to display my result in the new window like pop up window .along with other selected value in the drop box. here is my code.
function CalCost(a)
{
var area = a;
var Total_Cost = 0;
var max = 100;
if(a == 1)
{
J = 40;
D = 15;
E = 900;
P = 75;
L = 50;
E = 5;
M = 16;
Pi =8;
Pr = 34;
Ir = 52;
W = 42;
RK = 25;
Sp = 7;
Total_Cost = J+D+E+P+L+E+M+Pi+Pr+Ir+W+RK+Sp;
}
}
There are multiple ways of doing it , also I presume you are looking for a new window and not a modal or pop up window. For that you can use window.open
& update the value there
var win = window.open();
win.document.write(Total_Cost);
EDIT
First create a dom for modal
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<span class="close">×</span>
<p id ='calValue'></p> // calculated value will be show here
</div>
</div>
JS
// Get the button that opens the modal
var btn = document.getElementById("myBtn");
// 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";
}
}
Check demo here