Use jQuery to dynamically alter Form GET target on Submit
-
07-07-2019 - |
Question
I would like to submit a form, specifically an input field to a URL based on the input field's value using GET.
Example: Input field value is "test". Submit GETs www.myurl.com/Products/Search/test
Example: Input field value is empty. Submit GETs www.myurl.com/Products/Search/
Example: Input field value is "123". Submit GETs www.myurl.com/Products/Search/123
How could I do this using jQuery? Probably intercepting the submit..?? Thank you for your help!
Solution
$('form').submit(function() {
this.action += $('#myInput').val();
return true;
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow