brazenskies
02-10-2009, 09:27 AM
I'm new to ajax and having a bit of trouble with the 'onkeypress' event.
Here's the scenario...
User enters a search value into a text box, then clicks on an image to submit the request.
Image code...
<img src="images/btnTownSearch.jpg" alt="Submit Search" style="margin-top:4px;" onclick="runSearch()" />
function code...
function runSearch(){
if (document.frmSearch1.txtCP.value != "")
{
http = createRequestObject();
http.open('get', 'maptools/searchLocation.asp?search=' + document.frmSearch1.txtCP.value );
http.onreadystatechange = handleSearchResponse;
http.send(null);
}
else
{
alert("Please choose a centre point")
}
}
This works perfectly if you click on the image but I somehow need to modify the code to allow the request to be made when the user hits the 'enter' key.
Also, if it helps at all then here's a link to my page. (http://mapsinternational.co.uk/custom-wall-maps.asp)
Any help would be appreciated,
Thanks in advance!
Here's the scenario...
User enters a search value into a text box, then clicks on an image to submit the request.
Image code...
<img src="images/btnTownSearch.jpg" alt="Submit Search" style="margin-top:4px;" onclick="runSearch()" />
function code...
function runSearch(){
if (document.frmSearch1.txtCP.value != "")
{
http = createRequestObject();
http.open('get', 'maptools/searchLocation.asp?search=' + document.frmSearch1.txtCP.value );
http.onreadystatechange = handleSearchResponse;
http.send(null);
}
else
{
alert("Please choose a centre point")
}
}
This works perfectly if you click on the image but I somehow need to modify the code to allow the request to be made when the user hits the 'enter' key.
Also, if it helps at all then here's a link to my page. (http://mapsinternational.co.uk/custom-wall-maps.asp)
Any help would be appreciated,
Thanks in advance!