Last active
February 6, 2019 18:37
-
-
Save gchristofferson/de61bfec17a2b433565dafdfd92a7b49 to your computer and use it in GitHub Desktop.
Get users search input and add it to form action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get users search input and add it to form action | |
$('#js-search-input').keypress(function (e) { | |
let key = e.which; | |
// if the key is the enter key code | |
if(key === 13) { | |
const userInput = $('#js-search-input').val(); | |
console.log("user input: " + userInput); | |
let actionStr = "/inquiries/search/" + userInput; | |
console.log("actionStr = " + actionStr); | |
actionStr = actionStr.replace('?', ''); | |
// window.location.replace(actionStr); | |
document.getElementById('js-search-form').action = actionStr; | |
} | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment