I have an input on my page that I would like to use for search. I would like the page to jump to the location of the user's input value.
HTML:
<input name="searchInput" type="text" id="searchInputOne" class="searchInput" />
<input type="button" id="submitButton" value="Search" />
JS:
var input = document.getElementById("searchInputOne");
var submit = document.getElementById("submitButton");
function search() {
window.location = window.location.href + "/" + input.value;
}
submit.onclick = search;
This makes sense in my head, but it doesn't work in practice. I'm sure my search
function is wrong. How can I make it right? I would like to stay with pure JS.