I would like to show what I write in the input, but everytime I try the alert window shows "undefined". This is the code. Thanks.
<body>
<input id="input"></input>
<button id="search">search</button>
<script>
document.getElementById('search').addEventListener("click", show);
var input = getElementById('input');
var search = input.value;
function show() {
alert(search);
}
</script>
</body>