Coding a popup box with more than 1 input in JavaScript

It is extremely simple to code a popup box with more than 1 input in JavaScript. Here is the code snippet for your reference. (Run Code)

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();

GITEX Dubai Talk by Saion Gupta and Saiasmi Gupta

Good morning, everyone. I'm Saion Gupta, the Founder of 10xCoderKids and the Guinness World Record holder for the youngest computer prog...