Hi
i am trying to get a search box to work on both click a button or an enter action yet i cant get the enter action to work as well as enter.
I know this isnt strictly php but i am using all php functions with the search and wondered if anyone could help.
This is my code:
<script type="text/javascript">
function get() {
$.post('search_tsr.php', { search_term: form.name.value },
function(output) {
$('#search_results').html(output).show();
});
}
$(document).ready(function() {
$(document).keyup(function(event) {
if (event.keyCode == 13) {
$("#form").submit();
$.post('search_tsr.php', { search_term: form.name.value },
function(output) {
$('#search_results').html(output).show();
});
}
})
});
</script>
The form is below:
<form name="form">
<img src="gfx/search_magnifyer.jpg" width="18" height="18" border="0" align="absmiddle">
<input name="name" type="text"><input type="button" onClick="get()" value="Go">
</form>
Anyone can you help?