Andrew O Neill Andrew O Neill - 1 year ago 37
Javascript Question

How to access a user input email without changing page in Javascript

So I want the user to write in an email in the input field, and then I want to take that input when the button is clicked, without changing page, as it ruins my routes.

<label for="email">Email:</label>
<input type="email" class="form-control" id="email" placeholder="Add Navigators Email so they can access the Session">

<button type="button" onclick="addNav()" class="btn btn-success">Add to Session</button><br>

I need to get the input of a user without changing page using solely javascript.
Is this possible?


You have to find the element by it's id and then get it's value:

email_input = document.getElementById("email");

Working example: