I'm pretty new on JavaScript, I wrote a code to redirect user into another page based on what they typed in a search bar.
The weird thing is, it sometimes works sometimes don't (half half), someone might know what could cause this?
my HTML
<form class="form-inline my-2 my-lg-0">
    <input id="inputName" class="form-control mr-sm-2" type="search"
           placeholder="Search">
    <button id="searchBtn" class="btn btn-outline-success my-2 my-sm-0" onclick="searchUser()" type="button">
        Search
    </button>
</form>
my javascript
function searchUser() {
    window.open("/user/" + String(document.getElementById('inputName').value));
}
Update: Thank you for point out dual id, I have deleted extra id but the issue remains.
It could happen to all string, eg., "hsy", it sometimes work, sometimes don't.
When searching from URL http://127.0.0.1:8000/user/hsy, if it doesn't work, the URL just display as http://127.0.0.1:8000/user/hsy? with an extra question mark at the end of the URL.
 
     
    