How do I get my code to accept user input and store it in the variable so they can search locations? [duplicate]

So, I am making an application that will allow users to search by city, state code, and country code to find the weather in that area using the OpenWeather API key.

I already stored my API key like so, in the JavaScript file (key is hidden, I’m not sure if it is sensitive material. Better safe than sorry!):

// The stored API key for the Weather Application
var APIKey = "********************************";

So now all I need to do is figure out how to get my code to accept user input to search by city, state code, and country code.

I started by putting in a form where you can type in text, but how do I get the code to take that text and store it in these variables on the .js file?

var city;
var stateCode;
var countryCode;

Here is what my HTML Document looks like so far:

<!DOCTYPE html>
<html>
    <body>
        <nav class="navbar navbar-light bg-light">
            <form class="form-inline">
              <input class="form-control mr-sm-2" type="text" placeholder="Country">
              <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
            </form>
          </nav>

    </body>
</html>

I am not really familiar with JavaScript, but I am determined to get this to work.