so my question is pretty simple.
How to I get user input from a form and put it into a variable ?
Im struggling to do this simple task and would appreciate some help.
Here is my code :
html:
<body>
<form>
<input type="text" id="input_id" value="">
<input type="submit" value="Submit">
<div id="alert" style="color: red"></div>
</form>
</body>
Javascript
var a = document.getElementById('input_id').value;
function wawa() {
return a;
}
document.getElementById('alert').innerHTML = "user entered this value: " + " " + a;
I would like to do this with vanilla JS and no library.
Thanks.