var mywindow = window.open("", "_blank", "width=400, height=200");
mywindow.moveTo(450, 50);
function ok() {
var name = mywindow.document.getElementById('name').value;
var pass = mywindow.document.getElementById('pass').value;
mywindow.close();
alert('Name: ' + name + ' Password: ' + pass);
}
function cancel() {
mywindow.close();
}
mywindow.document.open();
mywindow.document.write("<html>
<head>
<title>Popup Box with 2 inputs | 10xCoderKids</title>
</head>
<body>
<p>Please enter your details:</p>
Name: <input id='name' /><br><br>
Password: <input id='pass' /><br><br>
<button id='submit'>Ok</button>
<button id='cancel'>Cancel</button>
</body>
</html>");
mywindow.document.getElementById('submit').addEventListener('click',function(){
ok();
})
mywindow.document.getElementById('cancel').addEventListener('click',function(){
cancel();
})
mywindow.document.close();