View Single Post
Old 01-28-2013, 12:00 PM   PM User | #1
sami.abid
New to the CF scene

 
Join Date: Jan 2013
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
sami.abid is an unknown quantity at this point
Script not recognizing the "Enter" keypress via keyboard

Hi there,

I am building a search box to use on our library website, I am very new to programming languages. I have made a small JavaScript and it has come out well as I am able to enter the search term and it redirects to an external website. However the search button is only working when I click on "search". When I press the enter button via keyboard after typing the search it doesn't recognize the keypress even though the script is meant to recognize the key press. Was wondering if you guys can help me please.

here's the script:

Quote:
<p><a id="logo" href="/"><img style="width: 137px; height: 24px;" title="SpringerLink" alt="Logo Springer" src="http://link.springer.com/static/0.6043/sites/link/images/logo.png" width="158" height="30" /></a></p>
<script type="text/javascript">// <![CDATA[

function econlitSearchGo(){
var url="http://link.springer.com/search?query=";
var url2=""
var searchInputeconlit = document.getElementById("econlitSearchInput");
window.open(url + encodeURIComponent(searchInputeconlit.value) + url2);
}
// ]]></script>
<div>
<div style="position: absolute; left: -1000em; width: 20em;" id="enterText">Enter your search terms:</div>
<input id="econlitSearchInput" onkeypress="handleKeyPress(event,this.form)" size="30" type="text" /><input onclick="econlitSearchGo()"value="Search" type="button" /></div>
sami.abid is offline   Reply With Quote