On click enter redirect to another URL with parameters in javascript
On click enter redirect to another URL with parameters in javascript
Through many examples, we will learn how to resolve the "On click enter redirect to another URL with parameters in javascript".
Sometimes you have to redirect user to another URL with parameters (query string) in javascript on click enter button. It also helps you to find the solution to show data with filtered data and redirect user to another URL on click enter button-
On click enter button visit a URL with parameter using jQuery
<!-- HTML Input text --> <input type="text" name="query" id="search" value="summer"/> <!-- jQuery CDN with javascript to redirect user to another URL after click on enter button --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $('#search').keypress(function (e) { var query = $.trim($(this).val()); if (e.which == 13) { window.location.href = "/search/all?keyword="+query; return false; } }); </script>
This code snippet will help you to redirect to another URL onclick enter button. It will redirect you to /search/all?keyword=summer URL after getting the value summer from input box on click enter button. This code snippet can be also used to display filtered data using parameter value which is passed as query string to URL.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Javascript
- Uncaught TypeError: Cannot read property 'addEventListener' of undefined
- Copy one array to another in javascript
- Multidimensional array example javascript
- How to open modal after redirect
- Deault order of record in datatable
- How to Set data to localstorage in javascript
- JavaScript test() Method
- How to crop multiple images with cropper js
- How to pass array as arguments to function in javascript
- ReferenceError: $ is not defined
- Remove property from object in javascript
- How to preview a word document in HTML using javascript
- Javascript set timeout function with example code
- How to add a property to object with condition in javascript
- Uncaught TypeError: $(...).summernote is not a function
- How to add key/value pair to existing form data
- Apex bar chart - fill bar color with gradient on hover
- How to show and hide placeholder text
- Apexcharts example code
- Remove hostname from URL in javascript
- How to get the length of a number in JavaScript
- How to switch between Dark Mode and Light Mode based on cookie in Javascript
- How to display for slash as a string in javascript HTML
- Uncaught TypeError: Illegal invocation
- Trim the leading and trailing comma from string in Javascript