get value for input in JS file

I have a js file with this code:

   <input onchange="this.value"/>
   <input type="pas" onchange="this.value"/>

This code get data for inputs and replace in main page. Now I don’t want replace in html page. I want get input’s value and save in string variable. for example:

var name =  ""; // input 1 
var Pas = ""; // input 2

How can this work?
Thank you.

You can give the input elements id(say, ‘name’ and ‘password’) and access it this way

var input1 = document.getElementById('name').value;
var input2 = document.getElementById('password').value;