JavaScript search box
- or -
Post a project like this3278
$15
- Posted:
- Proposals: 5
- Remote
- #739205
- Completed
Description
Experience Level: Entry
Estimated project duration: less than 1 week
General information for the website: JavaScript Help
Description of requirements/features: I'm looking for help. I have a free text search box. I have used JavaScript for when a user type in a search keyword and click on the search button the page is redirected to a URL with the keyword. But I can't the the "onkeydown" function to work when the user press the enter key. I need someone to look at the code and clean it up a bit. I don't think it should take too long. I'm a novice coder but figured most of it.
The following is the code I used for the search box:
jQuery(function($){
$("#Keywords").Watermark("Enter search parameters here (Title/Keywords/Abstract)");
});
function gtSearch(el) {
var url = el.getAttribute('url');
var keywords = encodeURIComponent(document.getElementById('Keywords').value);
var sUrl = url.replace("{{keywords}}", keywords);
window.location.href = sUrl;
}
Search
If you look at the above code the search button works fine, but its when adding the URL to the onkeydown when it fails.
Extra notes:
Description of requirements/features: I'm looking for help. I have a free text search box. I have used JavaScript for when a user type in a search keyword and click on the search button the page is redirected to a URL with the keyword. But I can't the the "onkeydown" function to work when the user press the enter key. I need someone to look at the code and clean it up a bit. I don't think it should take too long. I'm a novice coder but figured most of it.
The following is the code I used for the search box:
jQuery(function($){
$("#Keywords").Watermark("Enter search parameters here (Title/Keywords/Abstract)");
});
function gtSearch(el) {
var url = el.getAttribute('url');
var keywords = encodeURIComponent(document.getElementById('Keywords').value);
var sUrl = url.replace("{{keywords}}", keywords);
window.location.href = sUrl;
}
Search
If you look at the above code the search button works fine, but its when adding the URL to the onkeydown when it fails.
Extra notes:
Jacobus S.
100% (1)Projects Completed
3
Freelancers worked with
3
Projects awarded
8%
Last project
6 Apr 2015
United Kingdom
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies